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 17 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)), this, SLOT(file_info_slot(QModelIndex)));
40}
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 292 of file CustomFileView.cpp.

293{
294 QString file = model()->data(model()->index(index.row(), 0, index.parent())).toString();
295 QString path = model()->data(model()->index(index.row(), 1, index.parent())).toString();
296 auto full_name = path + "/" + file;
297 emit stateChanged(full_name);
298}
void stateChanged(const QString &FileName)

◆ ConnectActions()

void dbe::CustomFileView::ConnectActions ( )

Definition at line 70 of file CustomFileView.cpp.

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

◆ contextMenuEvent()

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

Reimplemented functions.

Definition at line 85 of file CustomFileView.cpp.

86{
87 QModelIndex index = indexAt(Event->pos());
88
89 if (index.isValid()) {
90 if (model()->data(model()->index(index.row(), 2)).toString() == "RO") {
91 ContextMenu->actions().at(0)->setVisible(false);
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 } else {
100 ContextMenu->actions().at(0)->setVisible(false);
101 ContextMenu->actions().at(1)->setVisible(false);
102 }
103 ContextMenu->exec(Event->globalPos());
104}

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

◆ CreateContextMenu()

void dbe::CustomFileView::CreateContextMenu ( )

Definition at line 76 of file CustomFileView.cpp.

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

◆ EditedSearchString [1/2]

void dbe::CustomFileView::EditedSearchString ( )
privateslot

Definition at line 285 of file CustomFileView.cpp.

286{
287 QString Dummy("Dummy");
288 EditedSearchString(Dummy);
289}
void EditedSearchString(QString Text)

◆ EditedSearchString [2/2]

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

Definition at line 273 of file CustomFileView.cpp.

274{
275 Q_UNUSED(Text)
276
277 connect(LineEdit, SIGNAL(returnPressed()), this, SLOT(GoToFile()));
278 disconnect(LineEdit, SIGNAL(returnPressed()), this, SLOT(GoToNext()));
279
280 GoButton->setEnabled(true);
281 NextButton->setDisabled(true);
282}

◆ file_info_slot [1/2]

void dbe::CustomFileView::file_info_slot ( )
privateslot

Definition at line 231 of file CustomFileView.cpp.

232{
233 file_info_slot(currentIndex());
234}

◆ file_info_slot [2/2]

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

Definition at line 237 of file CustomFileView.cpp.

238{
239 QString file = model()->data(model()->index(index.row(), 0, index.parent())).toString();
240 QString path = model()->data(model()->index(index.row(), 1, index.parent())).toString();
241 auto full_name = path + "/" + file;
242
243 FileInfo::show_file_info(full_name);
244}
static void show_file_info(const QString &filename)
Definition FileInfo.cpp:505

◆ FindFileSlot

void dbe::CustomFileView::FindFileSlot ( )
privateslot

Definition at line 182 of file CustomFileView.cpp.

183{
184 if (FindFileDialog != nullptr) {
185 delete FindFileDialog;
186 FindFileDialog = nullptr;
187 }
188
189 FindFileDialog = new QDialog(this);
190 FindFileDialog->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
191 FindFileDialog->setToolTip("Type string to edit line and press Enter.");
192 FindFileDialog->setWindowTitle("Search for a file name in the table");
193
194 QHBoxLayout* FileLayout = new QHBoxLayout();
195 QLabel* Label = new QLabel(QString("Find File:"));
196 NextButton = new QPushButton("Next");
197 GoButton = new QPushButton("Go !");
198 LineEdit = new QLineEdit();
199 LineEdit->setToolTip("Type string and press Enter");
200
201 FileLayout->addWidget(Label);
202 FileLayout->addWidget(LineEdit);
203 FileLayout->addWidget(GoButton);
204 FileLayout->addWidget(NextButton);
205
206 QHBoxLayout* ButtonsLayout = new QHBoxLayout();
207 WholeWordCheckBox = new QCheckBox("Whole String");
208 CaseSensitiveCheckBox = new QCheckBox("Case Sensitive");
209
210 ButtonsLayout->addWidget(WholeWordCheckBox);
211 ButtonsLayout->addWidget(CaseSensitiveCheckBox);
212
213 QVBoxLayout* FindDialogLayout = new QVBoxLayout();
214 FindDialogLayout->addItem(FileLayout);
215 FindDialogLayout->addItem(ButtonsLayout);
216
217 FindFileDialog->setLayout(FindDialogLayout);
218 FindFileDialog->show();
219 // NextButton->setDisabled(true);
220
221 connect(LineEdit, SIGNAL(textEdited(QString)), this, SLOT(EditedSearchString(QString)));
222 connect(WholeWordCheckBox, SIGNAL(clicked()), this, SLOT(EditedSearchString()));
223 connect(CaseSensitiveCheckBox, SIGNAL(clicked()), this, SLOT(EditedSearchString()));
224
225 connect(LineEdit, SIGNAL(returnPressed()), this, SLOT(GoToFile()));
226 connect(GoButton, SIGNAL(clicked()), this, SLOT(GoToFile()));
227 connect(NextButton, SIGNAL(clicked()), this, SLOT(GoToNext()));
228}
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 return;
116 }
117
118 QAbstractItemModel* Model = model();
119
120 if (Model != nullptr) {
121 QVariant StringCriterium = QVariant(UserType);
122
123 QModelIndex find_by_name = Model->index(0, 0);
124 QModelIndex find_by_path = Model->index(0, 1);
125
126 Qt::MatchFlags options = Qt::MatchContains;
127
128 if (CaseSensitiveCheckBox->isChecked()) {
129 options = options | Qt::MatchCaseSensitive;
130 }
131
132 if (WholeWordCheckBox->isChecked()) {
133 options = Qt::MatchExactly;
134 }
135
136 ListOfMatch = Model->match(find_by_name, Qt::DisplayRole, StringCriterium, 1000, options);
137
138 ListOfMatch.append(Model->match(find_by_path, Qt::DisplayRole, StringCriterium, 1000, options));
139
140 if (ListOfMatch.size() > 0) {
141 ListIndex = 0;
142 scrollTo(ListOfMatch.value(ListIndex), QAbstractItemView::EnsureVisible);
143 selectRow(ListOfMatch.value(ListIndex).row());
144 resizeColumnToContents(ListIndex);
145
146 GoButton->setDisabled(true);
147 NextButton->setEnabled(true);
148
149 disconnect(LineEdit, SIGNAL(returnPressed()), this, SLOT(GoToFile()));
150 connect(LineEdit, SIGNAL(returnPressed()), this, SLOT(GoToNext()));
152 }
153 }
154}
QModelIndexList ListOfMatch
int ListIndex
Match Variables.

◆ GoToNext

void dbe::CustomFileView::GoToNext ( )
privateslot

Definition at line 157 of file CustomFileView.cpp.

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

◆ HideReadOnlyFilesSlot

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

Definition at line 259 of file CustomFileView.cpp.

260{
261 for (int i = 0; i < model()->rowCount(); ++i) {
262 if (model()->data(model()->index(i, 2)).toString() == "RO") {
263 if (Hide) {
264 hideRow(i);
265 } else {
266 showRow(i);
267 }
268 }
269 }
270}

◆ LaunchIncludeEditorSlot

void dbe::CustomFileView::LaunchIncludeEditorSlot ( )
privateslot

Definition at line 247 of file CustomFileView.cpp.

248{
249 QModelIndex index = currentIndex();
250 QString file = model()->data(model()->index(index.row(), 0, index.parent())).toString();
251 QString path = model()->data(model()->index(index.row(), 1, index.parent())).toString();
252 auto full_name = path + "/" + file;
253 auto* file_widget = new IncludeFileWidget(full_name);
254
255 file_widget->show();
256}
IncludeFileWidget(QString FilePath, QWidget *parent=0)

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