DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
apps
SchemaEditor
SchemaCustomFileModel.cpp
Go to the documentation of this file.
1
2
#include "
dbe/SchemaCustomFileModel.hpp
"
3
#include "
dbe/SchemaKernelWrapper.hpp
"
4
#include "
dbe/SchemaStyle.hpp
"
6
#include <vector>
7
8
#include <QBrush>
9
#include <QColor>
10
#include <QSize>
11
12
dbse::CustomFileModel::CustomFileModel
( QStringList & Headers, QObject * parent )
13
: QAbstractTableModel ( parent ),
14
HeaderList
( Headers )
15
{
16
setupModel
();
17
}
18
19
dbse::CustomFileModel::~CustomFileModel
()
20
{
21
}
22
23
int
dbse::CustomFileModel::rowCount
(
const
QModelIndex & parent )
const
24
{
25
Q_UNUSED ( parent );
26
return
Data
.size();
27
}
28
29
int
dbse::CustomFileModel::columnCount
(
const
QModelIndex & parent )
const
30
{
31
Q_UNUSED ( parent );
32
return
HeaderList
.size();
33
}
34
35
// Qt::ItemFlags dbse::CustomFileModel::flags ( const QModelIndex & index ) const
36
// {
37
// // if ( Data.value (index.row() ).value ( 1) == "RW" ) {
38
// return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
39
// // }
40
// // else {
41
// // return Qt::NoItemFlags;
42
// // }
43
// }
44
45
QVariant
dbse::CustomFileModel::headerData
(
int
section, Qt::Orientation orientation,
46
int
role )
const
47
{
48
if
( role != Qt::DisplayRole )
49
{
50
return
QVariant();
51
}
52
53
if
( orientation == Qt::Horizontal )
54
{
55
return
HeaderList
.at ( section );
56
}
57
58
return
QVariant();
59
}
60
61
QVariant
dbse::CustomFileModel::data
(
const
QModelIndex & index,
int
role )
const
62
{
63
if
( role == Qt::DisplayRole ) {
64
return
Data
.value(index.row()).value(index.column());
65
}
66
if
(role == Qt::ForegroundRole) {
67
if
(
Data
.value(index.row()).value(2).contains(
"Active"
)) {
68
return
QBrush(QColor (
SchemaStyle::get_color
(
"foreground"
,
"active_file"
)));
69
}
70
if
(
Data
.value(index.row()).value(1) ==
"RW"
) {
71
return
QBrush(QColor (
SchemaStyle::get_color
(
"foreground"
,
"default"
)));
72
}
73
return
QBrush(
SchemaStyle::get_color
(
"foreground"
,
"readonly"
));
74
}
75
if
(role == Qt::BackgroundRole) {
76
if
(
Data
.value(index.row()).value(2).contains(
"Active"
)) {
77
return
QBrush(QColor (
SchemaStyle::get_color
(
"background"
,
"active_file"
)));
78
}
79
if
(
Data
.value(index.row()).value(1) ==
"RW"
) {
80
return
QBrush(QColor (
SchemaStyle::get_color
(
"background"
,
"default"
)));
81
}
82
return
QBrush(
SchemaStyle::get_color
(
"background"
,
"readonly"
));
83
}
84
if
(role == Qt::ToolTipRole) {
85
return
Data
.value(index.row()).value(0);
86
}
87
88
return
QVariant();
89
}
90
91
void
dbse::CustomFileModel::setupModel
()
92
{
93
std::vector<std::string> SchemaFiles;
94
KernelWrapper::GetInstance
().
GetSchemaFiles
( SchemaFiles );
95
std::string ActiveSchema =
KernelWrapper::GetInstance
().
GetActiveSchema
();
96
std::string Modified =
KernelWrapper::GetInstance
().
ModifiedSchemaFiles
();
97
for
( std::string & FileName : SchemaFiles )
98
{
99
QStringList Row;
100
Row.append ( QString::fromStdString ( FileName ) );
101
102
if
(
KernelWrapper::GetInstance
().IsFileWritable ( FileName ) )
103
{
104
Row.append (
"RW"
);
105
}
106
else
107
{
108
Row.append (
"RO"
);
109
}
110
111
std::string Status =
""
;
112
if
( Modified.find( FileName ) != std::string::npos) {
113
Status =
"Modified"
;
114
}
115
if
( FileName == ActiveSchema) {
116
if
( !Status.empty() ) {
117
Status +=
" "
;
118
}
119
Status +=
"Active"
;
120
}
121
122
Row.append ( QString::fromStdString ( Status ) );
123
Data
.append ( Row );
124
}
125
}
126
127
QStringList
dbse::CustomFileModel::getRowFromIndex
( QModelIndex & index )
128
{
129
if
( !index.isValid() )
130
{
131
return
QStringList();
132
}
133
134
return
Data
.at ( index.row() );
135
}
SchemaCustomFileModel.hpp
SchemaKernelWrapper.hpp
SchemaStyle.hpp
dbse::CustomFileModel::Data
QList< QStringList > Data
Definition
SchemaCustomFileModel.hpp:31
dbse::CustomFileModel::getRowFromIndex
QStringList getRowFromIndex(QModelIndex &index)
Definition
SchemaCustomFileModel.cpp:127
dbse::CustomFileModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition
SchemaCustomFileModel.cpp:45
dbse::CustomFileModel::HeaderList
QStringList HeaderList
Definition
SchemaCustomFileModel.hpp:30
dbse::CustomFileModel::data
QVariant data(const QModelIndex &index, int role) const
Definition
SchemaCustomFileModel.cpp:61
dbse::CustomFileModel::~CustomFileModel
~CustomFileModel()
Definition
SchemaCustomFileModel.cpp:19
dbse::CustomFileModel::setupModel
void setupModel()
Definition
SchemaCustomFileModel.cpp:91
dbse::CustomFileModel::columnCount
int columnCount(const QModelIndex &parent) const
Definition
SchemaCustomFileModel.cpp:29
dbse::CustomFileModel::rowCount
int rowCount(const QModelIndex &parent) const
Definition
SchemaCustomFileModel.cpp:23
dbse::CustomFileModel::CustomFileModel
CustomFileModel(QStringList &Headers, QObject *parent=nullptr)
Including Schema Editor.
Definition
SchemaCustomFileModel.cpp:12
dbse::KernelWrapper::GetActiveSchema
std::string GetActiveSchema() const
Definition
SchemaKernelWrapper.cpp:65
dbse::KernelWrapper::GetInstance
static KernelWrapper & GetInstance()
Definition
SchemaKernelWrapper.cpp:18
dbse::KernelWrapper::ModifiedSchemaFiles
std::string ModifiedSchemaFiles() const
Definition
SchemaKernelWrapper.cpp:196
dbse::KernelWrapper::GetSchemaFiles
void GetSchemaFiles(std::vector< std::string > &SchemaFiles)
Definition
SchemaKernelWrapper.cpp:99
dbse::SchemaStyle::get_color
static QColor get_color(const QString &item, const QString &group)
Definition
SchemaStyle.cpp:103
Generated on
for DUNE-DAQ by
1.17.0