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 18 of file CustomFileView.hpp.

Constructor & Destructor Documentation

◆ CustomFileView()

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

Including QT Headers.

Including DBE

Definition at line 22 of file CustomFileView.cpp.

23 : QTableView ( parent ),
24 ContextMenu ( nullptr ),
25 LaunchIncludeEditor ( nullptr ),
26 HideReadOnlyFiles ( nullptr ),
27 FindFile ( nullptr ),
28 FindFileDialog ( nullptr ),
29 LineEdit ( nullptr ),
30 NextButton ( nullptr ),
31 GoButton ( nullptr )
32{
35 setSelectionBehavior ( SelectionBehavior::SelectRows );
36 horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeMode::Stretch );
37 setSortingEnabled ( true );
38
39 connect ( this, SIGNAL(activated(QModelIndex)),
40 this, SLOT(file_info_slot(QModelIndex)) );
41}
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 310 of file CustomFileView.cpp.

311{
312 QString file = model()->data ( model()->index ( index.row(), 0,
313 index.parent() ) ).toString();
314 QString path = model()->data ( model()->index ( index.row(), 1,
315 index.parent() ) ).toString();
316 auto full_name = path + "/" + file;
317 emit stateChanged ( full_name );
318}
void stateChanged(const QString &FileName)

◆ ConnectActions()

void dbe::CustomFileView::ConnectActions ( )

Definition at line 73 of file CustomFileView.cpp.

74{
75 connect ( this, SIGNAL ( clicked ( QModelIndex ) ), this,
76 SLOT ( ChangeSelection ( QModelIndex ) ) );
77}
void ChangeSelection(QModelIndex Index)

◆ contextMenuEvent()

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

Reimplemented functions.

Definition at line 88 of file CustomFileView.cpp.

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

◆ CreateActions()

void dbe::CustomFileView::CreateActions ( )

Definition at line 43 of file CustomFileView.cpp.

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 m_file_info_action = new QAction (tr ("File &information"));
52 connect ( m_file_info_action, SIGNAL(triggered()),
53 this, SLOT(file_info_slot()) );
54 ContextMenu->addAction ( m_file_info_action );
55
56 HideReadOnlyFiles = new QAction ( tr ( "Hide Read Only Files" ), this );
57 HideReadOnlyFiles->setShortcutContext ( Qt::WidgetShortcut );
58 HideReadOnlyFiles->setCheckable ( true );
59 HideReadOnlyFiles->setChecked ( false );
60 connect ( HideReadOnlyFiles, SIGNAL ( triggered ( bool ) ), this,
61 SLOT ( HideReadOnlyFilesSlot ( bool ) ) );
62 ContextMenu->addAction ( HideReadOnlyFiles );
63
64
65 FindFile = new QAction ( tr ( "Find File" ), this );
66 FindFile->setShortcut ( QKeySequence ( tr ( "Ctrl+F" ) ) );
67 FindFile->setShortcutContext ( Qt::WidgetShortcut );
68 connect ( FindFile, SIGNAL ( triggered() ), this, SLOT ( FindFileSlot() ) );
69// connect ( Shortcut, SIGNAL ( activated() ), this, SLOT ( FindFileSlot() ) );
70 ContextMenu->addAction ( FindFile );
71}
void HideReadOnlyFilesSlot(bool Hide)

◆ CreateContextMenu()

void dbe::CustomFileView::CreateContextMenu ( )

Definition at line 79 of file CustomFileView.cpp.

80{
81 if ( ContextMenu == nullptr )
82 {
83 ContextMenu = new QMenu ( this );
85 }
86}

◆ EditedSearchString [1/2]

void dbe::CustomFileView::EditedSearchString ( )
privateslot

Definition at line 304 of file CustomFileView.cpp.

305{
306 QString Dummy ( "Dummy" );
307 EditedSearchString ( Dummy );
308}

◆ EditedSearchString [2/2]

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

Definition at line 293 of file CustomFileView.cpp.

294{
295 Q_UNUSED ( Text )
296
297 connect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToFile() ) );
298 disconnect ( LineEdit, SIGNAL ( returnPressed() ), this, SLOT ( GoToNext() ) );
299
300 GoButton->setEnabled ( true );
301 NextButton->setDisabled ( true );
302}

◆ file_info_slot [1/2]

void dbe::CustomFileView::file_info_slot ( )
privateslot

Definition at line 248 of file CustomFileView.cpp.

248 {
249 file_info_slot(currentIndex());
250}

◆ file_info_slot [2/2]

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

Definition at line 252 of file CustomFileView.cpp.

252 {
253 QString file = model()->data ( model()->index ( index.row(), 0,
254 index.parent() ) ).toString();
255 QString path = model()->data ( model()->index ( index.row(), 1,
256 index.parent() ) ).toString();
257 auto full_name = path + "/" + file;
258
259 FileInfo::show_file_info(full_name);
260}
static void show_file_info(const QString &filename)
Definition FileInfo.cpp:454

◆ FindFileSlot

void dbe::CustomFileView::FindFileSlot ( )
privateslot

Definition at line 197 of file CustomFileView.cpp.

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

◆ GoToFile

void dbe::CustomFileView::GoToFile ( )
privateslot

Definition at line 112 of file CustomFileView.cpp.

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

◆ GoToNext

void dbe::CustomFileView::GoToNext ( )
privateslot

Definition at line 168 of file CustomFileView.cpp.

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

◆ HideReadOnlyFilesSlot

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

Definition at line 275 of file CustomFileView.cpp.

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

◆ LaunchIncludeEditorSlot

void dbe::CustomFileView::LaunchIncludeEditorSlot ( )
privateslot

Definition at line 262 of file CustomFileView.cpp.

263{
264 QModelIndex index = currentIndex();
265 QString file = model()->data ( model()->index ( index.row(), 0,
266 index.parent() ) ).toString();
267 QString path = model()->data ( model()->index ( index.row(), 1,
268 index.parent() ) ).toString();
269 auto full_name = path + "/" + file;
270 auto * file_widget = new IncludeFileWidget ( full_name );
271
272 file_widget->show();
273}

◆ stateChanged

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

Member Data Documentation

◆ CaseSensitiveCheckBox

QCheckBox* dbe::CustomFileView::CaseSensitiveCheckBox
private

Definition at line 41 of file CustomFileView.hpp.

◆ ContextMenu

QMenu* dbe::CustomFileView::ContextMenu
private

Context menu with the possible actions.

Definition at line 30 of file CustomFileView.hpp.

◆ FindFile

QAction* dbe::CustomFileView::FindFile
private

Definition at line 33 of file CustomFileView.hpp.

◆ FindFileDialog

QDialog* dbe::CustomFileView::FindFileDialog
private

File Dialog.

Definition at line 36 of file CustomFileView.hpp.

◆ GoButton

QPushButton* dbe::CustomFileView::GoButton
private

Definition at line 39 of file CustomFileView.hpp.

◆ HideReadOnlyFiles

QAction* dbe::CustomFileView::HideReadOnlyFiles
private

Definition at line 32 of file CustomFileView.hpp.

◆ LaunchIncludeEditor

QAction* dbe::CustomFileView::LaunchIncludeEditor
private

Definition at line 31 of file CustomFileView.hpp.

◆ LineEdit

QLineEdit* dbe::CustomFileView::LineEdit
private

Definition at line 37 of file CustomFileView.hpp.

◆ ListIndex

int dbe::CustomFileView::ListIndex
private

Match Variables.

Definition at line 43 of file CustomFileView.hpp.

◆ ListOfMatch

QModelIndexList dbe::CustomFileView::ListOfMatch
private

Definition at line 44 of file CustomFileView.hpp.

◆ m_file_info_action

QAction* dbe::CustomFileView::m_file_info_action
private

Definition at line 34 of file CustomFileView.hpp.

◆ NextButton

QPushButton* dbe::CustomFileView::NextButton
private

Definition at line 38 of file CustomFileView.hpp.

◆ WholeWordCheckBox

QCheckBox* dbe::CustomFileView::WholeWordCheckBox
private

Definition at line 40 of file CustomFileView.hpp.


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