DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SchemaCustomFileModel.cpp
Go to the documentation of this file.
1
5#include <vector>
6
7#include <QSize>
8
9dbse::CustomFileModel::CustomFileModel ( QStringList & Headers, QObject * parent )
10 : QAbstractTableModel ( parent ),
11 HeaderList ( Headers )
12{
13 setupModel();
14}
15
19
20int dbse::CustomFileModel::rowCount ( const QModelIndex & parent ) const
21{
22 Q_UNUSED ( parent )
23 return Data.size();
24}
25
26int dbse::CustomFileModel::columnCount ( const QModelIndex & parent ) const
27{
28 Q_UNUSED ( parent )
29 return HeaderList.size();
30}
31
32Qt::ItemFlags dbse::CustomFileModel::flags ( const QModelIndex & index ) const
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}
41
42QVariant dbse::CustomFileModel::headerData ( int section, Qt::Orientation orientation,
43 int role ) const
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}
57
58QVariant dbse::CustomFileModel::data ( const QModelIndex & index, int role ) const
59{
60 if ( role != Qt::DisplayRole )
61 {
62 return QVariant();
63 }
64
65 return Data.value ( index.row() ).value ( index.column() );
66}
67
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}
103
104QStringList dbse::CustomFileModel::getRowFromIndex ( QModelIndex & index )
105{
106 if ( !index.isValid() )
107 {
108 return QStringList();
109 }
110
111 return Data.at ( index.row() );
112}
QStringList getRowFromIndex(QModelIndex &index)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
QVariant data(const QModelIndex &index, int role) const
Qt::ItemFlags flags(const QModelIndex &index) const
int columnCount(const QModelIndex &parent) const
int rowCount(const QModelIndex &parent) const
CustomFileModel(QStringList &Headers, QObject *parent=nullptr)
Including Schema Editor.
std::string GetActiveSchema() const
static KernelWrapper & GetInstance()
std::string ModifiedSchemaFiles() const
void GetSchemaFiles(std::vector< std::string > &SchemaFiles)