DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbse::CustomFileModel Class Reference

#include <SchemaCustomFileModel.hpp>

Inheritance diagram for dbse::CustomFileModel:
[legend]
Collaboration diagram for dbse::CustomFileModel:
[legend]

Public Member Functions

 CustomFileModel (QStringList &Headers, QObject *parent=nullptr)
 Including Schema Editor.
 
 ~CustomFileModel ()
 
int rowCount (const QModelIndex &parent) const
 
int columnCount (const QModelIndex &parent) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const
 
QVariant data (const QModelIndex &index, int role) const
 
void setupModel ()
 
QStringList getRowFromIndex (QModelIndex &index)
 

Private Attributes

QStringList HeaderList
 
QList< QStringList > Data
 

Detailed Description

Definition at line 11 of file SchemaCustomFileModel.hpp.

Constructor & Destructor Documentation

◆ CustomFileModel()

dbse::CustomFileModel::CustomFileModel ( QStringList & Headers,
QObject * parent = nullptr )
explicit

Including Schema Editor.

Including C++ Headers

Definition at line 12 of file SchemaCustomFileModel.cpp.

13 : QAbstractTableModel ( parent ),
14 HeaderList ( Headers )
15{
16 setupModel();
17}

◆ ~CustomFileModel()

dbse::CustomFileModel::~CustomFileModel ( )

Definition at line 19 of file SchemaCustomFileModel.cpp.

20{
21}

Member Function Documentation

◆ columnCount()

int dbse::CustomFileModel::columnCount ( const QModelIndex & parent) const

Definition at line 29 of file SchemaCustomFileModel.cpp.

30{
31 Q_UNUSED ( parent );
32 return HeaderList.size();
33}

◆ data()

QVariant dbse::CustomFileModel::data ( const QModelIndex & index,
int role ) const

Definition at line 61 of file SchemaCustomFileModel.cpp.

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}
static QColor get_color(const QString &item, const QString &group)

◆ getRowFromIndex()

QStringList dbse::CustomFileModel::getRowFromIndex ( QModelIndex & index)

Definition at line 127 of file SchemaCustomFileModel.cpp.

128{
129 if ( !index.isValid() )
130 {
131 return QStringList();
132 }
133
134 return Data.at ( index.row() );
135}

◆ headerData()

QVariant dbse::CustomFileModel::headerData ( int section,
Qt::Orientation orientation,
int role ) const

Definition at line 45 of file SchemaCustomFileModel.cpp.

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}

◆ rowCount()

int dbse::CustomFileModel::rowCount ( const QModelIndex & parent) const

Definition at line 23 of file SchemaCustomFileModel.cpp.

24{
25 Q_UNUSED ( parent );
26 return Data.size();
27}

◆ setupModel()

void dbse::CustomFileModel::setupModel ( )

Definition at line 91 of file SchemaCustomFileModel.cpp.

92{
93 std::vector<std::string> 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}
std::string GetActiveSchema() const
static KernelWrapper & GetInstance()
std::string ModifiedSchemaFiles() const
void GetSchemaFiles(std::vector< std::string > &SchemaFiles)

Member Data Documentation

◆ Data

QList<QStringList> dbse::CustomFileModel::Data
private

Definition at line 26 of file SchemaCustomFileModel.hpp.

◆ HeaderList

QStringList dbse::CustomFileModel::HeaderList
private

Definition at line 25 of file SchemaCustomFileModel.hpp.


The documentation for this class was generated from the following files: