17 m_ptxtDir =
new QLineEdit(QCoreApplication::applicationDirPath());
18 m_ptxtMask =
new QLineEdit(
"*");
19 m_ptxtResult =
new QTextEdit;
21 QLabel* plblDir =
new QLabel(
"&Directory");
22 QLabel* plblMask =
new QLabel(
"&Mask");
23 QPushButton* pcmdDir =
new QPushButton(QPixmap(
":/fileopen.png"),
"");
24 QPushButton* pcmdFind =
new QPushButton(
"&Find");
26 connect(pcmdDir, SIGNAL(clicked()), SLOT(
slotBrowse()));
27 connect(pcmdFind, SIGNAL(clicked()), SLOT(
slotFind()));
29 plblDir->setBuddy(m_ptxtDir);
30 plblMask->setBuddy(m_ptxtMask);
33 QGridLayout* pgrdLayout =
new QGridLayout;
34 pgrdLayout->setContentsMargins(5, 5, 5, 5);
35 pgrdLayout->setSpacing(15);
36 pgrdLayout->addWidget(plblDir, 0, 0);
37 pgrdLayout->addWidget(plblMask, 1, 0);
38 pgrdLayout->addWidget(m_ptxtDir, 0, 1);
39 pgrdLayout->addWidget(m_ptxtMask, 1, 1);
40 pgrdLayout->addWidget(pcmdDir, 0, 2);
41 pgrdLayout->addWidget(pcmdFind, 1, 2);
42 pgrdLayout->addWidget(m_ptxtResult, 2, 0, 1, 3);
43 setLayout(pgrdLayout);
49 QString str = QFileDialog::getExistingDirectory(0,
55 m_ptxtDir->setText(str);
62 start(QDir(m_ptxtDir->text()));
68 QApplication::processEvents();
70 QStringList listFiles =
71 dir.entryList(m_ptxtMask->text().split(
" "), QDir::Files);
73 foreach (QString file, listFiles) {
74 m_ptxtResult->append(dir.absoluteFilePath(file));
77 QStringList listDir = dir.entryList(QDir::Dirs);
78 foreach (QString subdir, listDir) {
79 if (subdir ==
"." || subdir ==
"..") {
82 start(QDir(dir.absoluteFilePath(subdir)));
void start(const QDir &dir)
FileFinder(QWidget *pwgt=0)