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

#include <FileModel.hpp>

Inheritance diagram for dbe::FileModel:
[legend]
Collaboration diagram for dbe::FileModel:
[legend]

Signals

void FileCacheReady (QList< QStringList > &Files)
 

Public Member Functions

 ~FileModel ()
 
 FileModel (QObject *parent=nullptr)
 Including QT Headers.
 
 FileModel (QList< QStringList > const &FileList, QObject *parent=nullptr)
 
int rowCount (const QModelIndex &parent) const
 
int columnCount (const QModelIndex &parent) const
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 
Qt::ItemFlags flags (const QModelIndex &index) const
 
QString GetFullFileName (QString &FileName)
 
QList< QStringList > GetFilesInfo () const
 

Private Member Functions

void initpaths ()
 
void initmodel ()
 
void initconnections ()
 

Private Attributes

QList< QStringList > IncludedFiles
 
QStringList FolderPathList
 
QStringList Headers
 

Detailed Description

Definition at line 11 of file FileModel.hpp.

Constructor & Destructor Documentation

◆ ~FileModel()

dbe::FileModel::~FileModel ( )

Definition at line 31 of file FileModel.cpp.

32{}

◆ FileModel() [1/2]

dbe::FileModel::FileModel ( QObject * parent = nullptr)
explicit

Including QT Headers.

Including DBE Headers

Definition at line 12 of file FileModel.cpp.

13 : QAbstractTableModel ( parent ),
15{ tr ( "Name" ), tr ( "Folder" ), tr ( "Permission" ) }
16{
17 initpaths();
19 initmodel();
20}
void initconnections()
QStringList Headers
Definition FileModel.hpp:43

◆ FileModel() [2/2]

dbe::FileModel::FileModel ( QList< QStringList > const & FileList,
QObject * parent = nullptr )
explicit

Definition at line 22 of file FileModel.cpp.

23 : QAbstractTableModel ( parent ),
24 IncludedFiles ( FileList ),
26{ tr ( "Name" ), tr ( "Folder" ), tr ( "Permission" ) }
27{
29}
QList< QStringList > IncludedFiles
Definition FileModel.hpp:41

Member Function Documentation

◆ columnCount()

int dbe::FileModel::columnCount ( const QModelIndex & parent) const

Definition at line 44 of file FileModel.cpp.

45{
46 Q_UNUSED ( parent )
47 return Headers.size();
48}

◆ data()

QVariant dbe::FileModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const

Definition at line 50 of file FileModel.cpp.

51{
52 if ( index.isValid() )
53 {
54 if ( role == Qt::DisplayRole )
55 return QVariant (
56 IncludedFiles.at ( index.row() ).at ( index.column() ) );
57 }
58
59 return QVariant();
60}

◆ FileCacheReady

void dbe::FileModel::FileCacheReady ( QList< QStringList > & Files)
signal

◆ flags()

Qt::ItemFlags dbe::FileModel::flags ( const QModelIndex & index) const

Definition at line 81 of file FileModel.cpp.

82{
83 if ( IncludedFiles.at ( index.row() ).at ( static_cast<int>
84 ( tablepositions::filepermission ) ) == "RW" )
85 {
86 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
87 }
88
89 return Qt::ItemIsSelectable;
90}

◆ GetFilesInfo()

QList< QStringList > dbe::FileModel::GetFilesInfo ( ) const

Definition at line 142 of file FileModel.cpp.

143{
144 return IncludedFiles;
145}

◆ GetFullFileName()

QString dbe::FileModel::GetFullFileName ( QString & FileName)

Definition at line 120 of file FileModel.cpp.

121{
122 QFileInfo FileInfo ( FileName );
123
124 if ( FileInfo.isRelative() )
125 {
126
127 for ( const QString & Folder : FolderPathList )
128 {
129 QDir TdaqFolder ( Folder );
130
131 if ( TdaqFolder.exists ( FileName ) )
132 {
133 FileName = TdaqFolder.path() + "/" + FileName;
134 break;
135 }
136 }
137 }
138
139 return FileName;
140}
QStringList FolderPathList
Definition FileModel.hpp:42

◆ headerData()

QVariant dbe::FileModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const

Definition at line 62 of file FileModel.cpp.

64{
65 if ( role == Qt::DisplayRole )
66 {
67 if ( orientation == Qt::Horizontal )
68 {
69 return Headers.at ( section );
70 }
71
72 if ( orientation == Qt::Vertical )
73 {
74 return section + 1;
75 }
76 }
77
78 return QVariant();
79}
Missing configuration section
Message.

◆ initconnections()

void dbe::FileModel::initconnections ( )
private

Definition at line 114 of file FileModel.cpp.

115{
116 connect ( this, SIGNAL ( FileCacheReady ( QList<QStringList> & ) ), &confaccessor::ref(),
117 SLOT ( GetFileCache ( QList<QStringList> & ) ) );
118}
void FileCacheReady(QList< QStringList > &Files)
static confaccessor & ref()

◆ initmodel()

void dbe::FileModel::initmodel ( )
private

Definition at line 147 of file FileModel.cpp.

148{
149 QStringList sources = dbe::config::api::get::file::inclusions (
151
152 for ( QString const & source : sources )
153 {
154
155 QFileInfo srcinfo ( source );
156 QString fn = srcinfo.filePath();
157
158 for ( QString const & path : FolderPathList )
159 {
160 if ( fn.startsWith ( path ) )
161 {
162 fn = fn.replace ( 0, path.size(), "" );
163 break;
164 }
165 }
166
167 IncludedFiles.append ( QStringList{ srcinfo.fileName(), fn, confaccessor::check_file_rw ( source ) ? "RW" : "RO" } );
168 }
169
170 if ( IncludedFiles.size() )
171 {
173 }
174}
static bool check_file_rw(const QString &FileName)
static QString dbfullname()
static QStringList inclusions(QStringList const &candidates, QStringList files={ })

◆ initpaths()

void dbe::FileModel::initpaths ( )
private

Definition at line 92 of file FileModel.cpp.

93{
94 QString TDAQ_DB_REPOSITORY = getenv ( "TDAQ_DB_REPOSITORY" );
95 if(TDAQ_DB_REPOSITORY.isEmpty() == false) {
96 QString TDAQ_DB_USER_REPOSITORY = getenv ( "TDAQ_DB_USER_REPOSITORY" );
97 FolderPathList = TDAQ_DB_USER_REPOSITORY.split ( ":", QString::SkipEmptyParts );
98
100 } else {
101 QString DUNEDAQ_DB_PATH = getenv ( "DUNEDAQ_DB_PATH" );
102 FolderPathList = DUNEDAQ_DB_PATH.split ( ":", QString::SkipEmptyParts );
103 }
104
105 for ( QString & PathName : FolderPathList )
106 {
107 if ( !PathName.endsWith ( "/" ) )
108 {
109 PathName.append ( "/" );
110 }
111 }
112}
QString find_db_repository_dir()
static MainWindow * findthis()

◆ rowCount()

int dbe::FileModel::rowCount ( const QModelIndex & parent) const

Definition at line 34 of file FileModel.cpp.

35{
36 if ( !parent.isValid() )
37 {
38 return IncludedFiles.size();
39 }
40
41 return 0;
42}

Member Data Documentation

◆ FolderPathList

QStringList dbe::FileModel::FolderPathList
private

Definition at line 42 of file FileModel.hpp.

◆ Headers

QStringList dbe::FileModel::Headers
private

Definition at line 43 of file FileModel.hpp.

◆ IncludedFiles

QList<QStringList> dbe::FileModel::IncludedFiles
private

Definition at line 41 of file FileModel.hpp.


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