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)
 

Private Attributes

QMenu * ContextMenu
 Context menu with the possible actions.
 
QAction * LaunchIncludeEditor
 
QAction * HideReadOnlyFiles
 
QAction * FindFile
 
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 16 of file CustomFileView.cpp.

17 : QTableView ( parent ),
18 ContextMenu ( nullptr ),
19 LaunchIncludeEditor ( nullptr ),
20 HideReadOnlyFiles ( nullptr ),
21 FindFile ( nullptr ),
22 FindFileDialog ( nullptr ),
23 LineEdit ( nullptr ),
24 NextButton ( nullptr ),
25 GoButton ( nullptr )
26{
29 setSelectionBehavior ( SelectionBehavior::SelectRows );
30 horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeMode::Stretch );
31 setSortingEnabled ( true );
32}
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 268 of file CustomFileView.cpp.

269{
270 QString Data = model()->data ( model()->index ( Index.row(), 1,
271 Index.parent() ) ).toString();
272 emit stateChanged ( Data );
273}
void stateChanged(const QString &FileName)
nlohmann::json Data
Definition Structs.hpp:24

◆ ConnectActions()

void dbe::CustomFileView::ConnectActions ( )

Definition at line 60 of file CustomFileView.cpp.

61{
62 connect ( this, SIGNAL ( clicked ( QModelIndex ) ), this,
63 SLOT ( ChangeSelection ( QModelIndex ) ) );
64}
void ChangeSelection(QModelIndex Index)

◆ contextMenuEvent()

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

Reimplemented functions.

Definition at line 75 of file CustomFileView.cpp.

76{
77 QModelIndex Index = indexAt ( Event->pos() );
78
79 if ( Index.isValid() )
80 {
81 setCurrentIndex ( Index );
82 selectionModel()->setCurrentIndex ( Index, QItemSelectionModel::NoUpdate );
83 ContextMenu->exec ( Event->globalPos() );
84 }
85}

◆ CreateActions()

void dbe::CustomFileView::CreateActions ( )

Definition at line 34 of file CustomFileView.cpp.

35{
36 QShortcut * Shortcut = new QShortcut ( QKeySequence ( tr ( "Ctrl+F" ) ), this );
37
38 FindFile = new QAction ( tr ( "Find File" ), this );
39 FindFile->setShortcut ( QKeySequence ( tr ( "Ctrl+F" ) ) );
40 FindFile->setShortcutContext ( Qt::WidgetShortcut );
41 connect ( FindFile, SIGNAL ( triggered() ), this, SLOT ( FindFileSlot() ) );
42 connect ( Shortcut, SIGNAL ( activated() ), this, SLOT ( FindFileSlot() ) );
43 ContextMenu->addAction ( FindFile );
44
45 LaunchIncludeEditor = new QAction ( tr ( "Add/Remove Files" ), this );
46 LaunchIncludeEditor->setShortcutContext ( Qt::WidgetShortcut );
47 connect ( LaunchIncludeEditor, SIGNAL ( triggered() ), this,
48 SLOT ( LaunchIncludeEditorSlot() ) );
49 ContextMenu->addAction ( LaunchIncludeEditor );
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}
void HideReadOnlyFilesSlot(bool Hide)

◆ CreateContextMenu()

void dbe::CustomFileView::CreateContextMenu ( )

Definition at line 66 of file CustomFileView.cpp.

67{
68 if ( ContextMenu == nullptr )
69 {
70 ContextMenu = new QMenu ( this );
72 }
73}

◆ EditedSearchString [1/2]

void dbe::CustomFileView::EditedSearchString ( )
privateslot

Definition at line 262 of file CustomFileView.cpp.

263{
264 QString Dummy ( "Dummy" );
265 EditedSearchString ( Dummy );
266}

◆ EditedSearchString [2/2]

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

Definition at line 251 of file CustomFileView.cpp.

252{
253 Q_UNUSED ( Text )
254
255 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToFile() ) );
256 disconnect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToNext() ) );
257
258 GoButton->setEnabled ( true );
259 NextButton->setDisabled ( true );
260}

◆ FindFileSlot

void dbe::CustomFileView::FindFileSlot ( )
privateslot

Definition at line 172 of file CustomFileView.cpp.

173{
174 if ( FindFileDialog != nullptr )
175 {
176 delete FindFileDialog;
177 FindFileDialog = nullptr;
178 }
179
180 FindFileDialog = new QDialog ( this );
181 FindFileDialog->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
182 FindFileDialog->setToolTip ( "Type string to edit line and press Enter." );
183 FindFileDialog->setWindowTitle ( "Search for a file name in the table" );
184
185 QHBoxLayout * FileLayout = new QHBoxLayout();
186 QLabel * Label = new QLabel ( QString ( "Find File:" ) );
187 NextButton = new QPushButton ( "Next" );
188 GoButton = new QPushButton ( "Go !" );
189 LineEdit = new QLineEdit();
190 LineEdit->setToolTip ( "Type string and press Enter" );
191
192 FileLayout->addWidget ( Label );
193 FileLayout->addWidget ( LineEdit );
194 FileLayout->addWidget ( GoButton );
195 FileLayout->addWidget ( NextButton );
196
197 QHBoxLayout * ButtonsLayout = new QHBoxLayout();
198 WholeWordCheckBox = new QCheckBox ( "Whole String" );
199 CaseSensitiveCheckBox = new QCheckBox ( "Case Sensitive" );
200
201 ButtonsLayout->addWidget ( WholeWordCheckBox );
202 ButtonsLayout->addWidget ( CaseSensitiveCheckBox );
203
204 QVBoxLayout * FindDialogLayout = new QVBoxLayout();
205 FindDialogLayout->addItem ( FileLayout );
206 FindDialogLayout->addItem ( ButtonsLayout );
207
208 FindFileDialog->setLayout ( FindDialogLayout );
209 FindFileDialog->show();
210 //NextButton->setDisabled(true);
211
212 connect ( LineEdit, SIGNAL ( textEdited ( QString ) ), this,
213 SLOT ( EditedSearchString ( QString ) ) );
214 connect ( WholeWordCheckBox, SIGNAL ( clicked() ), this, SLOT ( EditedSearchString() ) );
215 connect ( CaseSensitiveCheckBox, SIGNAL ( clicked() ), this,
216 SLOT ( EditedSearchString() ) );
217
218 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToFile() ) );
219 connect ( GoButton, SIGNAL ( clicked() ), this, SLOT ( GoToFile() ) );
220 connect ( NextButton, SIGNAL ( clicked() ), this, SLOT ( GoToNext() ) );
221}
QCheckBox * CaseSensitiveCheckBox
QCheckBox * WholeWordCheckBox

◆ GoToFile

void dbe::CustomFileView::GoToFile ( )
privateslot

Definition at line 87 of file CustomFileView.cpp.

88{
89 ListIndex = 0;
90 ListOfMatch.clear();
91
92 QString UserType = LineEdit->text();
93
94 if ( UserType.isEmpty() )
95 {
96 return;
97 }
98
99 QAbstractItemModel * Model = model();
100
101 if ( Model != nullptr )
102 {
103 QVariant StringCriterium = QVariant ( UserType );
104
105 QModelIndex find_by_name = Model->index ( 0, 0 );
106 QModelIndex find_by_path = Model->index ( 0, 1 );
107
108 Qt::MatchFlags options = Qt::MatchContains;
109
110 if ( CaseSensitiveCheckBox->isChecked() )
111 {
112 options = options | Qt::MatchCaseSensitive;
113 }
114
115 if ( WholeWordCheckBox->isChecked() )
116 {
117 options = Qt::MatchExactly;
118 }
119
120 ListOfMatch = Model->match ( find_by_name, Qt::DisplayRole, StringCriterium, 1000,
121 options );
122
123 ListOfMatch.append (
124 Model->match ( find_by_path, Qt::DisplayRole, StringCriterium, 1000, options ) );
125
126 if ( ListOfMatch.size() > 0 )
127 {
128 ListIndex = 0;
129 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
130 selectRow ( ListOfMatch.value ( ListIndex ).row() );
131 resizeColumnToContents ( ListIndex );
132
133 GoButton->setDisabled ( true );
134 NextButton->setEnabled ( true );
135
136 disconnect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToFile() ) );
137 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToNext() ) );
139 }
140 }
141}
QModelIndexList ListOfMatch
int ListIndex
Match Variables.

◆ GoToNext

void dbe::CustomFileView::GoToNext ( )
privateslot

Definition at line 143 of file CustomFileView.cpp.

144{
145 if ( ( LineEdit->text() ).isEmpty() )
146 {
147 ListIndex = 0;
148 ListOfMatch.clear();
149 return;
150 }
151
152 if ( ListOfMatch.size() > 0 )
153 {
154 if ( ( ++ListIndex ) < ListOfMatch.size() )
155 {
156 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
157 selectRow ( ListOfMatch.value ( ListIndex ).row() );
158 resizeColumnToContents ( ListIndex );
160 }
161 else
162 {
163 ListIndex = 0;
164 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
165 selectRow ( ListOfMatch.value ( ListIndex ).row() );
166 resizeColumnToContents ( ListIndex );
168 }
169 }
170}

◆ HideReadOnlyFilesSlot

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

Definition at line 233 of file CustomFileView.cpp.

234{
235 for ( int i = 0; i < model()->rowCount(); ++i )
236 {
237 if ( model()->data ( model()->index ( i, 2 ) ).toString() == "RO" )
238 {
239 if ( Hide )
240 {
241 hideRow ( i );
242 }
243 else
244 {
245 showRow ( i );
246 }
247 }
248 }
249}

◆ LaunchIncludeEditorSlot

void dbe::CustomFileView::LaunchIncludeEditorSlot ( )
privateslot

Definition at line 223 of file CustomFileView.cpp.

224{
225 QModelIndex Index = currentIndex();
226 QString Data = model()->data ( model()->index ( Index.row(), 1,
227 Index.parent() ) ).toString();
228
229 IncludeFileWidget * FileWidget = new IncludeFileWidget ( Data );
230 FileWidget->show();
231}

◆ stateChanged

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

Member Data Documentation

◆ CaseSensitiveCheckBox

QCheckBox* dbe::CustomFileView::CaseSensitiveCheckBox
private

Definition at line 35 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 30 of file CustomFileView.hpp.

◆ GoButton

QPushButton* dbe::CustomFileView::GoButton
private

Definition at line 33 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 31 of file CustomFileView.hpp.

◆ ListIndex

int dbe::CustomFileView::ListIndex
private

Match Variables.

Definition at line 37 of file CustomFileView.hpp.

◆ ListOfMatch

QModelIndexList dbe::CustomFileView::ListOfMatch
private

Definition at line 38 of file CustomFileView.hpp.

◆ NextButton

QPushButton* dbe::CustomFileView::NextButton
private

Definition at line 32 of file CustomFileView.hpp.

◆ WholeWordCheckBox

QCheckBox* dbe::CustomFileView::WholeWordCheckBox
private

Definition at line 34 of file CustomFileView.hpp.


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