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

#include <CustomFileView.hpp>

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

Signals

void stateChanged (const QString &FileName)
 

Public Member Functions

 CustomFileView (QWidget *parent=nullptr)
 Including QT Headers.
 
void CreateActions ()
 
void ConnectActions ()
 
void CreateContextMenu ()
 
void contextMenuEvent (QContextMenuEvent *Event)
 Reimplemented functions.
 

Private Slots

void GoToFile ()
 
void GoToNext ()
 
void FindFileSlot ()
 
void LaunchIncludeEditorSlot ()
 
void HideReadOnlyFilesSlot (bool Hide)
 
void EditedSearchString (QString Text)
 
void EditedSearchString ()
 
void ChangeSelection (QModelIndex Index)
 
void file_info_slot ()
 
void file_info_slot (QModelIndex index)
 

Private Attributes

QMenu * ContextMenu
 Context menu with the possible actions.
 
QAction * LaunchIncludeEditor
 
QAction * HideReadOnlyFiles
 
QAction * FindFile
 
QAction * m_file_info_action
 
QDialog * FindFileDialog
 File Dialog.
 
QLineEdit * LineEdit
 
QPushButton * NextButton
 
QPushButton * GoButton
 
QCheckBox * WholeWordCheckBox
 
QCheckBox * CaseSensitiveCheckBox
 
int ListIndex
 Match Variables.
 
QModelIndexList ListOfMatch
 

Detailed Description

Definition at line 13 of file CustomFileView.hpp.

Constructor & Destructor Documentation

◆ CustomFileView()

dbe::CustomFileView::CustomFileView ( QWidget * parent = nullptr)

Including QT Headers.

Including DBE

Definition at line 17 of file CustomFileView.cpp.

18 : QTableView ( parent ),
19 ContextMenu ( nullptr ),
20 LaunchIncludeEditor ( nullptr ),
21 HideReadOnlyFiles ( nullptr ),
22 FindFile ( nullptr ),
23 FindFileDialog ( nullptr ),
24 LineEdit ( nullptr ),
25 NextButton ( nullptr ),
26 GoButton ( nullptr )
27{
30 setSelectionBehavior ( SelectionBehavior::SelectRows );
31 horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeMode::Stretch );
32 setSortingEnabled ( true );
33
34 connect ( this, SIGNAL(activated(QModelIndex)),
35 this, SLOT(file_info_slot(QModelIndex)) );
36}
QPushButton * NextButton
QMenu * ContextMenu
Context menu with the possible actions.
QDialog * FindFileDialog
File Dialog.

Member Function Documentation

◆ ChangeSelection

void dbe::CustomFileView::ChangeSelection ( QModelIndex Index)
privateslot

Definition at line 323 of file CustomFileView.cpp.

324{
325 QString file = model()->data ( model()->index ( index.row(), 0,
326 index.parent() ) ).toString();
327 QString path = model()->data ( model()->index ( index.row(), 1,
328 index.parent() ) ).toString();
329 auto full_name = path + "/" + file;
330 emit stateChanged ( full_name );
331}
void stateChanged(const QString &FileName)

◆ ConnectActions()

void dbe::CustomFileView::ConnectActions ( )

Definition at line 69 of file CustomFileView.cpp.

70{
71 connect ( this, SIGNAL ( clicked ( QModelIndex ) ), this,
72 SLOT ( ChangeSelection ( QModelIndex ) ) );
73}
void ChangeSelection(QModelIndex Index)

◆ contextMenuEvent()

void dbe::CustomFileView::contextMenuEvent ( QContextMenuEvent * Event)

Reimplemented functions.

Definition at line 84 of file CustomFileView.cpp.

85{
86 QModelIndex index = indexAt ( Event->pos() );
87
88 if ( index.isValid() )
89 {
90 if ( model()->data ( model()->index ( index.row(), 2 ) ).toString() == "RO" ) {
91 ContextMenu->actions().at ( 1 )->setVisible ( false );
92 }
93 else {
94 ContextMenu->actions().at ( 1 )->setVisible ( true );
95 }
96
97 setCurrentIndex ( index );
98 selectionModel()->setCurrentIndex ( index, QItemSelectionModel::NoUpdate );
99 ContextMenu->exec ( Event->globalPos() );
100 }
101}

◆ CreateActions()

void dbe::CustomFileView::CreateActions ( )

Definition at line 38 of file CustomFileView.cpp.

39{
40
41
42 FindFile = new QAction ( tr ( "Find File" ), this );
43 FindFile->setShortcut ( QKeySequence ( tr ( "Ctrl+F" ) ) );
44 FindFile->setShortcutContext ( Qt::WidgetShortcut );
45 connect ( FindFile, SIGNAL ( triggered() ), this, SLOT ( FindFileSlot() ) );
46// connect ( Shortcut, SIGNAL ( activated() ), this, SLOT ( FindFileSlot() ) );
47 ContextMenu->addAction ( FindFile );
48
49 LaunchIncludeEditor = new QAction ( tr ( "Add/Remove Files" ), this );
50 LaunchIncludeEditor->setShortcutContext ( Qt::WidgetShortcut );
51 connect ( LaunchIncludeEditor, SIGNAL ( triggered() ), this,
52 SLOT ( LaunchIncludeEditorSlot() ) );
53 ContextMenu->addAction ( LaunchIncludeEditor );
54
55 HideReadOnlyFiles = new QAction ( tr ( "Hide Read Only Files" ), this );
56 HideReadOnlyFiles->setShortcutContext ( Qt::WidgetShortcut );
57 HideReadOnlyFiles->setCheckable ( true );
58 HideReadOnlyFiles->setChecked ( false );
59 connect ( HideReadOnlyFiles, SIGNAL ( triggered ( bool ) ), this,
60 SLOT ( HideReadOnlyFilesSlot ( bool ) ) );
61 ContextMenu->addAction ( HideReadOnlyFiles );
62
63 m_file_info_action = new QAction (tr ("File &information"));
64 connect ( m_file_info_action, SIGNAL(triggered()),
65 this, SLOT(file_info_slot()) );
66 ContextMenu->addAction ( m_file_info_action );
67}
void HideReadOnlyFilesSlot(bool Hide)

◆ CreateContextMenu()

void dbe::CustomFileView::CreateContextMenu ( )

Definition at line 75 of file CustomFileView.cpp.

76{
77 if ( ContextMenu == nullptr )
78 {
79 ContextMenu = new QMenu ( this );
81 }
82}

◆ EditedSearchString [1/2]

void dbe::CustomFileView::EditedSearchString ( )
privateslot

Definition at line 317 of file CustomFileView.cpp.

318{
319 QString Dummy ( "Dummy" );
320 EditedSearchString ( Dummy );
321}

◆ EditedSearchString [2/2]

void dbe::CustomFileView::EditedSearchString ( QString Text)
privateslot

Definition at line 306 of file CustomFileView.cpp.

307{
308 Q_UNUSED ( Text )
309
310 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToFile() ) );
311 disconnect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToNext() ) );
312
313 GoButton->setEnabled ( true );
314 NextButton->setDisabled ( true );
315}

◆ file_info_slot [1/2]

void dbe::CustomFileView::file_info_slot ( )
privateslot

Definition at line 239 of file CustomFileView.cpp.

239 {
240 file_info_slot(currentIndex());
241}

◆ file_info_slot [2/2]

void dbe::CustomFileView::file_info_slot ( QModelIndex index)
privateslot

Definition at line 243 of file CustomFileView.cpp.

243 {
244 QString file = model()->data ( model()->index ( index.row(), 0,
245 index.parent() ) ).toString();
246 QString path = model()->data ( model()->index ( index.row(), 1,
247 index.parent() ) ).toString();
248 auto full_name = path + "/" + file;
249
251 full_name ) );
252 QString message{"Files included by " + file + "\n"};
253 bool schema=false;
254 for (auto inc: includes) {
255 if (schema && !inc.endsWith(".schema.xml")) {
256 message.append("\nData files:");
257 schema = false;
258 }
259 if (inc.endsWith(".schema.xml")) {
260 if (!schema) {
261 message.append("\nSchema files:");
262 schema = true;
263 }
264 }
265 message.append("\n " + inc);
266 }
267
268 QMessageBox mbox(this);
269 mbox.setWindowTitle(QString{"File information for " + file});
270 mbox.setStandardButtons(QMessageBox::Ok);
271 mbox.setText(message);
272 mbox.exec();
273}
static QStringList inclusions_singlefile(QString const &)

◆ FindFileSlot

void dbe::CustomFileView::FindFileSlot ( )
privateslot

Definition at line 188 of file CustomFileView.cpp.

189{
190 if ( FindFileDialog != nullptr )
191 {
192 delete FindFileDialog;
193 FindFileDialog = nullptr;
194 }
195
196 FindFileDialog = new QDialog ( this );
197 FindFileDialog->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
198 FindFileDialog->setToolTip ( "Type string to edit line and press Enter." );
199 FindFileDialog->setWindowTitle ( "Search for a file name in the table" );
200
201 QHBoxLayout * FileLayout = new QHBoxLayout();
202 QLabel * Label = new QLabel ( QString ( "Find File:" ) );
203 NextButton = new QPushButton ( "Next" );
204 GoButton = new QPushButton ( "Go !" );
205 LineEdit = new QLineEdit();
206 LineEdit->setToolTip ( "Type string and press Enter" );
207
208 FileLayout->addWidget ( Label );
209 FileLayout->addWidget ( LineEdit );
210 FileLayout->addWidget ( GoButton );
211 FileLayout->addWidget ( NextButton );
212
213 QHBoxLayout * ButtonsLayout = new QHBoxLayout();
214 WholeWordCheckBox = new QCheckBox ( "Whole String" );
215 CaseSensitiveCheckBox = new QCheckBox ( "Case Sensitive" );
216
217 ButtonsLayout->addWidget ( WholeWordCheckBox );
218 ButtonsLayout->addWidget ( CaseSensitiveCheckBox );
219
220 QVBoxLayout * FindDialogLayout = new QVBoxLayout();
221 FindDialogLayout->addItem ( FileLayout );
222 FindDialogLayout->addItem ( ButtonsLayout );
223
224 FindFileDialog->setLayout ( FindDialogLayout );
225 FindFileDialog->show();
226 //NextButton->setDisabled(true);
227
228 connect ( LineEdit, SIGNAL ( textEdited ( QString ) ), this,
229 SLOT ( EditedSearchString ( QString ) ) );
230 connect ( WholeWordCheckBox, SIGNAL ( clicked() ), this, SLOT ( EditedSearchString() ) );
231 connect ( CaseSensitiveCheckBox, SIGNAL ( clicked() ), this,
232 SLOT ( EditedSearchString() ) );
233
234 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToFile() ) );
235 connect ( GoButton, SIGNAL ( clicked() ), this, SLOT ( GoToFile() ) );
236 connect ( NextButton, SIGNAL ( clicked() ), this, SLOT ( GoToNext() ) );
237}
QCheckBox * CaseSensitiveCheckBox
QCheckBox * WholeWordCheckBox

◆ GoToFile

void dbe::CustomFileView::GoToFile ( )
privateslot

Definition at line 103 of file CustomFileView.cpp.

104{
105 ListIndex = 0;
106 ListOfMatch.clear();
107
108 QString UserType = LineEdit->text();
109
110 if ( UserType.isEmpty() )
111 {
112 return;
113 }
114
115 QAbstractItemModel * Model = model();
116
117 if ( Model != nullptr )
118 {
119 QVariant StringCriterium = QVariant ( UserType );
120
121 QModelIndex find_by_name = Model->index ( 0, 0 );
122 QModelIndex find_by_path = Model->index ( 0, 1 );
123
124 Qt::MatchFlags options = Qt::MatchContains;
125
126 if ( CaseSensitiveCheckBox->isChecked() )
127 {
128 options = options | Qt::MatchCaseSensitive;
129 }
130
131 if ( WholeWordCheckBox->isChecked() )
132 {
133 options = Qt::MatchExactly;
134 }
135
136 ListOfMatch = Model->match ( find_by_name, Qt::DisplayRole, StringCriterium, 1000,
137 options );
138
139 ListOfMatch.append (
140 Model->match ( find_by_path, Qt::DisplayRole, StringCriterium, 1000, options ) );
141
142 if ( ListOfMatch.size() > 0 )
143 {
144 ListIndex = 0;
145 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
146 selectRow ( ListOfMatch.value ( ListIndex ).row() );
147 resizeColumnToContents ( ListIndex );
148
149 GoButton->setDisabled ( true );
150 NextButton->setEnabled ( true );
151
152 disconnect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToFile() ) );
153 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToNext() ) );
155 }
156 }
157}
QModelIndexList ListOfMatch
int ListIndex
Match Variables.

◆ GoToNext

void dbe::CustomFileView::GoToNext ( )
privateslot

Definition at line 159 of file CustomFileView.cpp.

160{
161 if ( ( LineEdit->text() ).isEmpty() )
162 {
163 ListIndex = 0;
164 ListOfMatch.clear();
165 return;
166 }
167
168 if ( ListOfMatch.size() > 0 )
169 {
170 if ( ( ++ListIndex ) < ListOfMatch.size() )
171 {
172 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
173 selectRow ( ListOfMatch.value ( ListIndex ).row() );
174 resizeColumnToContents ( ListIndex );
176 }
177 else
178 {
179 ListIndex = 0;
180 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
181 selectRow ( ListOfMatch.value ( ListIndex ).row() );
182 resizeColumnToContents ( ListIndex );
184 }
185 }
186}

◆ HideReadOnlyFilesSlot

void dbe::CustomFileView::HideReadOnlyFilesSlot ( bool Hide)
privateslot

Definition at line 288 of file CustomFileView.cpp.

289{
290 for ( int i = 0; i < model()->rowCount(); ++i )
291 {
292 if ( model()->data ( model()->index ( i, 2 ) ).toString() == "RO" )
293 {
294 if ( Hide )
295 {
296 hideRow ( i );
297 }
298 else
299 {
300 showRow ( i );
301 }
302 }
303 }
304}

◆ LaunchIncludeEditorSlot

void dbe::CustomFileView::LaunchIncludeEditorSlot ( )
privateslot

Definition at line 275 of file CustomFileView.cpp.

276{
277 QModelIndex index = currentIndex();
278 QString file = model()->data ( model()->index ( index.row(), 0,
279 index.parent() ) ).toString();
280 QString path = model()->data ( model()->index ( index.row(), 1,
281 index.parent() ) ).toString();
282 auto full_name = path + "/" + file;
283 auto * file_widget = new IncludeFileWidget ( full_name );
284
285 file_widget->show();
286}

◆ stateChanged

void dbe::CustomFileView::stateChanged ( const QString & FileName)
signal

Member Data Documentation

◆ CaseSensitiveCheckBox

QCheckBox* dbe::CustomFileView::CaseSensitiveCheckBox
private

Definition at line 36 of file CustomFileView.hpp.

◆ ContextMenu

QMenu* dbe::CustomFileView::ContextMenu
private

Context menu with the possible actions.

Definition at line 25 of file CustomFileView.hpp.

◆ FindFile

QAction* dbe::CustomFileView::FindFile
private

Definition at line 28 of file CustomFileView.hpp.

◆ FindFileDialog

QDialog* dbe::CustomFileView::FindFileDialog
private

File Dialog.

Definition at line 31 of file CustomFileView.hpp.

◆ GoButton

QPushButton* dbe::CustomFileView::GoButton
private

Definition at line 34 of file CustomFileView.hpp.

◆ HideReadOnlyFiles

QAction* dbe::CustomFileView::HideReadOnlyFiles
private

Definition at line 27 of file CustomFileView.hpp.

◆ LaunchIncludeEditor

QAction* dbe::CustomFileView::LaunchIncludeEditor
private

Definition at line 26 of file CustomFileView.hpp.

◆ LineEdit

QLineEdit* dbe::CustomFileView::LineEdit
private

Definition at line 32 of file CustomFileView.hpp.

◆ ListIndex

int dbe::CustomFileView::ListIndex
private

Match Variables.

Definition at line 38 of file CustomFileView.hpp.

◆ ListOfMatch

QModelIndexList dbe::CustomFileView::ListOfMatch
private

Definition at line 39 of file CustomFileView.hpp.

◆ m_file_info_action

QAction* dbe::CustomFileView::m_file_info_action
private

Definition at line 29 of file CustomFileView.hpp.

◆ NextButton

QPushButton* dbe::CustomFileView::NextButton
private

Definition at line 33 of file CustomFileView.hpp.

◆ WholeWordCheckBox

QCheckBox* dbe::CustomFileView::WholeWordCheckBox
private

Definition at line 35 of file CustomFileView.hpp.


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