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 32 of file FileModel.cpp.

33{}

◆ FileModel() [1/2]

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

Including QT Headers.

Including DBE Headers

Definition at line 13 of file FileModel.cpp.

14 : QAbstractTableModel ( parent ),
16{ tr ( "Name" ), tr ( "Folder" ), tr ( "Access" ), tr ( "Status" ) }
17{
18 initpaths();
20 initmodel();
21}
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 23 of file FileModel.cpp.

24 : QAbstractTableModel ( parent ),
25 IncludedFiles ( FileList ),
27{ tr ( "Name" ), tr ( "Folder" ), tr ( "Access" ), tr ( "Status" ) }
28{
30}
QList< QStringList > IncludedFiles
Definition FileModel.hpp:41

Member Function Documentation

◆ columnCount()

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

Definition at line 45 of file FileModel.cpp.

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

◆ data()

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

Definition at line 51 of file FileModel.cpp.

52{
53 if ( index.isValid() )
54 {
55 if ( role == Qt::DisplayRole ) {
56 return QVariant (
57 IncludedFiles.at ( index.row() ).at ( index.column() ) );
58 }
59 if ( role == Qt::ForegroundRole )
60 {
61 if ( IncludedFiles.at ( index.row() ).at (
62 static_cast<int> ( tablepositions::filepermission ) ) == "RO" ) {
64 }
65 }
66 if ( role == Qt::BackgroundRole )
67 {
68 if ( IncludedFiles.at ( index.row() ).at (
69 static_cast<int> ( tablepositions::filepermission ) ) == "RO" ) {
71 }
72 }
73 }
74
75 return QVariant();
76}
static QColor FileReadOnlyForeground
static QColor FileReadOnlyBackground

◆ FileCacheReady

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

◆ flags()

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

Definition at line 97 of file FileModel.cpp.

98{
99 // if ( IncludedFiles.at ( index.row() ).at ( static_cast<int>
100 // ( tablepositions::filepermission ) ) == "RW" )
101 // {
102 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
103 // }
104
105 // return Qt::ItemIsSelectable;
106}

◆ GetFilesInfo()

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

Definition at line 162 of file FileModel.cpp.

163{
164 return IncludedFiles;
165}

◆ GetFullFileName()

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

Definition at line 136 of file FileModel.cpp.

137{
138 QFileInfo FileInfo ( FileName );
139
140 if ( FileInfo.isRelative() )
141 {
142 bool found=false;
143 for ( const QString & Folder : FolderPathList )
144 {
145 QDir TdaqFolder ( Folder );
146
147 if ( TdaqFolder.exists ( FileName ) )
148 {
149 FileName = TdaqFolder.path() + "/" + FileName;
150 found=true;
151 break;
152 }
153 }
154 if (!found) {
155 FileName = FileInfo.absoluteFilePath();
156 }
157 }
158
159 return FileName;
160}
QStringList FolderPathList
Definition FileModel.hpp:42

◆ headerData()

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

Definition at line 78 of file FileModel.cpp.

80{
81 if ( role == Qt::DisplayRole )
82 {
83 if ( orientation == Qt::Horizontal )
84 {
85 return Headers.at ( section );
86 }
87
88 if ( orientation == Qt::Vertical )
89 {
90 return section + 1;
91 }
92 }
93
94 return QVariant();
95}
Missing configuration section
Message.

◆ initconnections()

void dbe::FileModel::initconnections ( )
private

Definition at line 130 of file FileModel.cpp.

131{
132 connect ( this, SIGNAL ( FileCacheReady ( QList<QStringList> & ) ), &confaccessor::ref(),
133 SLOT ( GetFileCache ( QList<QStringList> & ) ) );
134}
void FileCacheReady(QList< QStringList > &Files)
static confaccessor & ref()

◆ initmodel()

void dbe::FileModel::initmodel ( )
private

Definition at line 167 of file FileModel.cpp.

168{
169 QStringList sources = dbe::config::api::get::file::inclusions (
171
172 std::list<std::string> updated = confaccessor::uncommitted_files();
173 for ( QString const & source : sources )
174 {
175 QFileInfo srcinfo ( source );
176 QString fn = srcinfo.filePath();
177 QString dn = GetFullFileName(fn).remove(QRegularExpression("/[a-zA-Z0-9_-]*.data.xml"));
178
179 QString modified{};
180 auto file = GetFullFileName(fn).toStdString();
181 for (auto ufile: updated) {
182 if (file == ufile) {
183 modified = "Modified";
184 break;
185 }
186 }
187
188 IncludedFiles.append ( QStringList{ srcinfo.fileName(),
189 dn,
190 confaccessor::check_file_rw ( source ) ? "RW" : "RO",
191 modified}
192 );
193 }
194
195 if ( IncludedFiles.size() )
196 {
198 }
199}
QString GetFullFileName(QString &FileName)
static std::list< std::string > uncommitted_files()
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 108 of file FileModel.cpp.

109{
110 QString TDAQ_DB_REPOSITORY = getenv ( "TDAQ_DB_REPOSITORY" );
111 if(TDAQ_DB_REPOSITORY.isEmpty() == false) {
112 QString TDAQ_DB_USER_REPOSITORY = getenv ( "TDAQ_DB_USER_REPOSITORY" );
113 FolderPathList = TDAQ_DB_USER_REPOSITORY.split ( ":", Qt::SkipEmptyParts );
114
116 } else {
117 QString DUNEDAQ_DB_PATH = getenv ( "DUNEDAQ_DB_PATH" );
118 FolderPathList = DUNEDAQ_DB_PATH.split ( ":", Qt::SkipEmptyParts );
119 }
120
121 for ( QString & PathName : FolderPathList )
122 {
123 if ( !PathName.endsWith ( "/" ) )
124 {
125 PathName.append ( "/" );
126 }
127 }
128}
QString find_db_repository_dir()
static MainWindow * findthis()

◆ rowCount()

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

Definition at line 35 of file FileModel.cpp.

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

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: