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 305 of file CustomFileView.cpp.

306{
307 QString file = model()->data ( model()->index ( index.row(), 0,
308 index.parent() ) ).toString();
309 QString path = model()->data ( model()->index ( index.row(), 1,
310 index.parent() ) ).toString();
311 auto full_name = path + "/" + file;
312 emit stateChanged ( full_name );
313}
void stateChanged(const QString &FileName)

◆ ConnectActions()

void dbe::CustomFileView::ConnectActions ( )

Definition at line 68 of file CustomFileView.cpp.

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

◆ contextMenuEvent()

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

Reimplemented functions.

Definition at line 83 of file CustomFileView.cpp.

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

◆ CreateActions()

void dbe::CustomFileView::CreateActions ( )

Definition at line 38 of file CustomFileView.cpp.

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

◆ CreateContextMenu()

void dbe::CustomFileView::CreateContextMenu ( )

Definition at line 74 of file CustomFileView.cpp.

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

◆ EditedSearchString [1/2]

void dbe::CustomFileView::EditedSearchString ( )
privateslot

Definition at line 299 of file CustomFileView.cpp.

300{
301 QString Dummy ( "Dummy" );
302 EditedSearchString ( Dummy );
303}

◆ EditedSearchString [2/2]

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

Definition at line 288 of file CustomFileView.cpp.

289{
290 Q_UNUSED ( Text )
291
292 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToFile() ) );
293 disconnect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToNext() ) );
294
295 GoButton->setEnabled ( true );
296 NextButton->setDisabled ( true );
297}

◆ file_info_slot [1/2]

void dbe::CustomFileView::file_info_slot ( )
privateslot

Definition at line 243 of file CustomFileView.cpp.

243 {
244 file_info_slot(currentIndex());
245}

◆ file_info_slot [2/2]

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

Definition at line 247 of file CustomFileView.cpp.

247 {
248 QString file = model()->data ( model()->index ( index.row(), 0,
249 index.parent() ) ).toString();
250 QString path = model()->data ( model()->index ( index.row(), 1,
251 index.parent() ) ).toString();
252 auto full_name = path + "/" + file;
253
254 FileInfo::show_file_info(full_name);
255}
static void show_file_info(const QString &filename)
Definition FileInfo.cpp:383

◆ FindFileSlot

void dbe::CustomFileView::FindFileSlot ( )
privateslot

Definition at line 192 of file CustomFileView.cpp.

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

◆ GoToFile

void dbe::CustomFileView::GoToFile ( )
privateslot

Definition at line 107 of file CustomFileView.cpp.

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

◆ GoToNext

void dbe::CustomFileView::GoToNext ( )
privateslot

Definition at line 163 of file CustomFileView.cpp.

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

◆ HideReadOnlyFilesSlot

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

Definition at line 270 of file CustomFileView.cpp.

271{
272 for ( int i = 0; i < model()->rowCount(); ++i )
273 {
274 if ( model()->data ( model()->index ( i, 2 ) ).toString() == "RO" )
275 {
276 if ( Hide )
277 {
278 hideRow ( i );
279 }
280 else
281 {
282 showRow ( i );
283 }
284 }
285 }
286}

◆ LaunchIncludeEditorSlot

void dbe::CustomFileView::LaunchIncludeEditorSlot ( )
privateslot

Definition at line 257 of file CustomFileView.cpp.

258{
259 QModelIndex index = currentIndex();
260 QString file = model()->data ( model()->index ( index.row(), 0,
261 index.parent() ) ).toString();
262 QString path = model()->data ( model()->index ( index.row(), 1,
263 index.parent() ) ).toString();
264 auto full_name = path + "/" + file;
265 auto * file_widget = new IncludeFileWidget ( full_name );
266
267 file_widget->show();
268}

◆ 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: