26 #if defined (HAVE_CONFIG_H)
32 #include <QDialogButtonBox>
33 #include <QDirIterator>
34 #include <QFileDialog>
36 #include <QGridLayout>
38 #include <QHeaderView>
42 #include <QPushButton>
45 #include <QTextStream>
57 :
QDialog (p), m_octave_qobj (oct_qobj)
61 setWindowTitle (tr (
"Find Files"));
62 setWindowIcon (rmgr.
icon (
"edit-find"));
67 connect (
m_timer, SIGNAL (timeout (
void)),
72 QLabel *file_name_label =
new QLabel (tr (
"Named:"));
79 QLabel *start_dir_label =
new QLabel (tr (
"Start in:"));
83 QDir::currentPath ()).toString ());
94 m_recurse_dirs_check->setToolTip (tr (
"Search recursively through directories for matching files"));
122 m_file_list->setSelectionBehavior (QAbstractItemView::SelectRows);
123 m_file_list->setSelectionMode (QAbstractItemView::SingleSelection);
128 m_file_list->horizontalHeader ()->setSortIndicatorShown (
true);
129 #if defined (HAVE_QHEADERVIEW_SETSECTIONSCLICKABLE)
130 m_file_list->horizontalHeader ()->setSectionsClickable (
true);
132 m_file_list->horizontalHeader ()->setClickable (
true);
134 m_file_list->horizontalHeader ()->setStretchLastSection (
true);
136 static_cast<Qt::SortOrder
>
141 connect (
m_file_list, SIGNAL (doubleClicked (
const QModelIndex&)),
148 m_find_button->setToolTip (tr (
"Start search for matching files"));
159 QDialogButtonBox *button_box =
new QDialogButtonBox (Qt::Vertical);
160 button_box->addButton (
m_find_button, QDialogButtonBox::ActionRole);
161 button_box->addButton (
m_stop_button, QDialogButtonBox::ActionRole);
165 connect (button_box, SIGNAL (rejected (
void)),
this, SLOT (close (
void)));
168 QGroupBox *name_group =
new QGroupBox (tr (
"Filename/location"));
169 QGridLayout *name_layout =
new QGridLayout;
170 name_group->setLayout (name_layout);
172 name_layout->addWidget (file_name_label,1,1, 1,1);
175 name_layout->addWidget (start_dir_label,2,1);
178 name_layout->setColumnStretch (2,1);
185 QGroupBox *content_group =
new QGroupBox (tr (
"File contents"));
186 QGridLayout *content_layout =
new QGridLayout;
187 content_group->setLayout (content_layout);
190 content_layout->setColumnStretch (2,1);
193 QGridLayout *main_layout =
new QGridLayout;
194 main_layout->setSizeConstraint (QLayout::SetFixedSize);
195 main_layout->addWidget (name_group, 0, 0);
196 main_layout->addWidget (content_group, 1, 0);
197 main_layout->addWidget (button_box, 0, 1,3,1);
199 main_layout->setRowStretch (2,1);
202 setLayout (main_layout);
204 connect (
this, SIGNAL (finished (
int)),
this, SLOT (
handle_done (
int)));
220 int sort_column =
m_file_list->horizontalHeader ()->sortIndicatorSection ();
221 Qt::SortOrder sort_order
222 =
m_file_list->horizontalHeader ()->sortIndicatorOrder ();
255 QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags;
257 flags |= QDirIterator::Subdirectories;
259 QDir::Filters filters = QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files;
261 filters |= QDir::CaseSensitive;
263 QStringList nameFilters;
308 QString res_str = QString (tr (
"%1 match (es)")).arg (
m->rowCount ());
320 opts = QFileDialog::DontUseNativeDialog;
323 QFileDialog::getExistingDirectory (
this, tr (
"Set search directory"),
325 QFileDialog::Option (opts));
327 if (! dir.isEmpty ())
335 QFileInfo info =
m->fileInfo (idx);
337 if (idx.column () == 1)
391 QFile file (info.absoluteFilePath ());
392 if (file.open (QIODevice::ReadOnly))
394 QTextStream
stream (&file);
400 ? Qt::CaseInsensitive
406 match =
line.contains (match_str, cs);
408 while (!
line.isNull () && match ==
false);
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
QCheckBox * m_name_case_check
void file_selected(const QString &fileName)
QPushButton * m_stop_button
QStatusBar * m_status_bar
virtual ~find_files_dialog(void)
QPushButton * m_browse_button
QLineEdit * m_file_name_edit
QPushButton * m_close_button
QCheckBox * m_content_case_check
QCheckBox * m_recurse_dirs_check
void set_search_dir(const QString &dir)
void dir_selected(const QString &fileName)
base_qobject & m_octave_qobj
void item_double_clicked(const QModelIndex &)
QCheckBox * m_contains_text_check
QDirIterator * m_dir_iterator
QCheckBox * m_include_dirs_check
bool is_match(const QFileInfo &info)
void look_for_files(void)
find_files_dialog(QWidget *parent, base_qobject &oct_qobj)
QPushButton * m_find_button
QLineEdit * m_start_dir_edit
void browse_folders(void)
QLineEdit * m_contains_text_edit
gui_settings * get_settings(void) const
QIcon icon(const QString &icon_name, bool fallback=true)
const gui_pref ff_include_dirs("findfiles/include_dirs", QVariant(false))
const gui_pref ff_start_dir("findfiles/start_dir", QVariant(""))
const gui_pref ff_check_text("findfiles/check_text", QVariant(false))
const gui_pref ff_file_name("findfiles/file_name", QVariant("*"))
const gui_pref ff_recurse_dirs("findfiles/recurse_dirs", QVariant(false))
const gui_pref ff_content_case("findfiles/content_case", QVariant(false))
const gui_pref ff_sort_files_by_order("findfiles/sort_files_by_order", QVariant(Qt::AscendingOrder))
const gui_pref ff_column_state("findfiles/column_state", QVariant())
const gui_pref ff_sort_files_by_column("findfiles/sort_files_by_column", QVariant(0))
const gui_pref ff_name_case("findfiles/name_case", QVariant(false))
const gui_pref ff_contains_text("findfiles/contains_text", QVariant(""))
const gui_pref global_use_native_dialogs("use_native_file_dialogs", QVariant(true))