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
 
Qt::ItemFlags flags (const QModelIndex &index) 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 9 of file SchemaCustomFileModel.cpp.

10 : QAbstractTableModel ( parent ),
11 HeaderList ( Headers )
12{
13 setupModel();
14}

◆ ~CustomFileModel()

dbse::CustomFileModel::~CustomFileModel ( )

Definition at line 16 of file SchemaCustomFileModel.cpp.

17{
18}

Member Function Documentation

◆ columnCount()

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

Definition at line 26 of file SchemaCustomFileModel.cpp.

27{
28 Q_UNUSED ( parent )
29 return HeaderList.size();
30}

◆ data()

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

Definition at line 58 of file SchemaCustomFileModel.cpp.

59{
60 if ( role != Qt::DisplayRole )
61 {
62 return QVariant();
63 }
64
65 return Data.value ( index.row() ).value ( index.column() );
66}

◆ flags()

Qt::ItemFlags dbse::CustomFileModel::flags ( const QModelIndex & index) const

Definition at line 32 of file SchemaCustomFileModel.cpp.

33{
34 if ( Data.value (index.row() ).value ( 1) == "RW" ) {
35 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
36 }
37 else {
38 return Qt::NoItemFlags;
39 }
40}

◆ getRowFromIndex()

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

Definition at line 104 of file SchemaCustomFileModel.cpp.

105{
106 if ( !index.isValid() )
107 {
108 return QStringList();
109 }
110
111 return Data.at ( index.row() );
112}

◆ headerData()

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

Definition at line 42 of file SchemaCustomFileModel.cpp.

44{
45 if ( role != Qt::DisplayRole )
46 {
47 return QVariant();
48 }
49
50 if ( orientation == Qt::Horizontal )
51 {
52 return HeaderList.at ( section );
53 }
54
55 return QVariant();
56}

◆ rowCount()

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

Definition at line 20 of file SchemaCustomFileModel.cpp.

21{
22 Q_UNUSED ( parent )
23 return Data.size();
24}

◆ setupModel()

void dbse::CustomFileModel::setupModel ( )

Definition at line 68 of file SchemaCustomFileModel.cpp.

69{
70 std::vector<std::string> SchemaFiles;
72 std::string ActiveSchema = KernelWrapper::GetInstance().GetActiveSchema();
73 std::string Modified = KernelWrapper::GetInstance().ModifiedSchemaFiles();
74 for ( std::string & FileName : SchemaFiles )
75 {
76 QStringList Row;
77 Row.append ( QString::fromStdString ( FileName ) );
78
79 if ( KernelWrapper::GetInstance().IsFileWritable ( FileName ) )
80 {
81 Row.append ( "RW" );
82 }
83 else
84 {
85 Row.append ( "RO" );
86 }
87
88 std::string Status = "";
89 if ( Modified.find( FileName ) != std::string::npos) {
90 Status = "Modified";
91 }
92 if ( FileName == ActiveSchema) {
93 if ( !Status.empty() ) {
94 Status += " ";
95 }
96 Status += "Active";
97 }
98
99 Row.append ( QString::fromStdString ( Status ) );
100 Data.append ( Row );
101 }
102}
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: