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 16 of file FileModel.hpp.

Constructor & Destructor Documentation

◆ ~FileModel()

dbe::FileModel::~FileModel ( )

Definition at line 37 of file FileModel.cpp.

38{}

◆ FileModel() [1/2]

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

Including QT Headers.

Including DBE Headers

Definition at line 18 of file FileModel.cpp.

19 : QAbstractTableModel ( parent ),
21{ tr ( "Name" ), tr ( "Folder" ), tr ( "Access" ), tr ( "Status" ) }
22{
23 initpaths();
25 initmodel();
26}
void initconnections()
QStringList Headers
Definition FileModel.hpp:48

◆ FileModel() [2/2]

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

Definition at line 28 of file FileModel.cpp.

29 : QAbstractTableModel ( parent ),
30 IncludedFiles ( FileList ),
32{ tr ( "Name" ), tr ( "Folder" ), tr ( "Access" ), tr ( "Status" ) }
33{
35}
QList< QStringList > IncludedFiles
Definition FileModel.hpp:46

Member Function Documentation

◆ columnCount()

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

Definition at line 50 of file FileModel.cpp.

51{
52 Q_UNUSED ( parent )
53 return Headers.size();
54}

◆ data()

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

Definition at line 56 of file FileModel.cpp.

57{
58 if ( index.isValid() )
59 {
60 if ( role == Qt::DisplayRole ) {
61 return QVariant (
62 IncludedFiles.at ( index.row() ).at ( index.column() ) );
63 }
64 if ( role == Qt::ForegroundRole )
65 {
66 if ( IncludedFiles.at ( index.row() ).at (
67 static_cast<int> ( tablepositions::filepermission ) ) == "RO" ) {
69 }
70 }
71 if ( role == Qt::BackgroundRole )
72 {
73 if ( IncludedFiles.at ( index.row() ).at (
74 static_cast<int> ( tablepositions::filepermission ) ) == "RO" ) {
76 }
77 }
78 }
79
80 return QVariant();
81}
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 102 of file FileModel.cpp.

103{
104 // if ( IncludedFiles.at ( index.row() ).at ( static_cast<int>
105 // ( tablepositions::filepermission ) ) == "RW" )
106 // {
107 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
108 // }
109
110 // return Qt::ItemIsSelectable;
111}

◆ GetFilesInfo()

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

Definition at line 170 of file FileModel.cpp.

171{
172 return IncludedFiles;
173}

◆ GetFullFileName()

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

Definition at line 141 of file FileModel.cpp.

142{
143 QFileInfo FileInfo ( FileName );
144
145 if ( FileInfo.isRelative() )
146 {
147 bool found=false;
148 for ( const QString & Folder : FolderPathList )
149 {
150 QDir TdaqFolder ( Folder );
151
152 if ( TdaqFolder.exists ( FileName ) )
153 {
154 FileName = TdaqFolder.path() + "/" + FileName;
155 char* rpath = realpath(FileName.toStdString().c_str(), NULL);
156 FileName = QString(rpath);
157 free(rpath);
158 found=true;
159 break;
160 }
161 }
162 if (!found) {
163 FileName = FileInfo.absoluteFilePath();
164 }
165 }
166
167 return FileName;
168}
QStringList FolderPathList
Definition FileModel.hpp:47

◆ headerData()

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

Definition at line 83 of file FileModel.cpp.

85{
86 if ( role == Qt::DisplayRole )
87 {
88 if ( orientation == Qt::Horizontal )
89 {
90 return Headers.at ( section );
91 }
92
93 if ( orientation == Qt::Vertical )
94 {
95 return section + 1;
96 }
97 }
98
99 return QVariant();
100}
Missing configuration section
Message.

◆ initconnections()

void dbe::FileModel::initconnections ( )
private

Definition at line 135 of file FileModel.cpp.

136{
137 connect ( this, SIGNAL ( FileCacheReady ( QList<QStringList> & ) ), &confaccessor::ref(),
138 SLOT ( GetFileCache ( QList<QStringList> & ) ) );
139}
void FileCacheReady(QList< QStringList > &Files)
static confaccessor & ref()

◆ initmodel()

void dbe::FileModel::initmodel ( )
private

Definition at line 175 of file FileModel.cpp.

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

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

◆ rowCount()

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

Definition at line 40 of file FileModel.cpp.

41{
42 if ( !parent.isValid() )
43 {
44 return IncludedFiles.size();
45 }
46
47 return 0;
48}

Member Data Documentation

◆ FolderPathList

QStringList dbe::FileModel::FolderPathList
private

Definition at line 47 of file FileModel.hpp.

◆ Headers

QStringList dbe::FileModel::Headers
private

Definition at line 48 of file FileModel.hpp.

◆ IncludedFiles

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

Definition at line 46 of file FileModel.hpp.


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