Skip to content

Commit ba576fd

Browse files
committed
expose extensions
1 parent 4881d5e commit ba576fd

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

projectbrowser.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ProjectBrowser::ProjectBrowser(QObject *parent) : QObject(parent)
1010
{
1111
m_projectPath = QUrl::fromLocalFile(QFileInfo(QCoreApplication::applicationFilePath()).dir().path());
1212

13-
updateFiles();
13+
connect(this, &ProjectBrowser::extensionsChanged, this, &ProjectBrowser::updateFiles);
1414
}
1515

1616
QStringList ProjectBrowser::qmlFiles() const
@@ -23,11 +23,25 @@ QUrl ProjectBrowser::projectPath() const
2323
return m_projectPath;
2424
}
2525

26+
QStringList ProjectBrowser::extensions() const
27+
{
28+
return m_extensions;
29+
}
30+
2631
void ProjectBrowser::update()
2732
{
2833
updateFiles();
2934
}
3035

36+
void ProjectBrowser::setExtensions(const QStringList &extensions)
37+
{
38+
if (m_extensions == extensions)
39+
return;
40+
41+
m_extensions = extensions;
42+
emit extensionsChanged();
43+
}
44+
3145
void ProjectBrowser::updateFiles()
3246
{
3347
QStringList fileList;
@@ -37,7 +51,7 @@ void ProjectBrowser::updateFiles()
3751
while (it.hasNext()) {
3852
it.next();
3953
const auto &extension = it.fileInfo().completeSuffix();
40-
if (extension == "qml") {
54+
if (m_extensions.contains(extension, Qt::CaseInsensitive)) {
4155
fileList.append(it.fileInfo().filePath());
4256
}
4357
}

projectbrowser.h

+6
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,28 @@ class ProjectBrowser : public QObject
99
Q_OBJECT
1010
Q_PROPERTY(QStringList qmlFiles READ qmlFiles NOTIFY qmlFilesChanged)
1111
Q_PROPERTY(QUrl projectPath READ projectPath CONSTANT)
12+
Q_PROPERTY(QStringList extensions READ extensions WRITE setExtensions NOTIFY extensionsChanged)
1213

1314
public:
1415
explicit ProjectBrowser(QObject *parent = nullptr);
1516

1617
QStringList qmlFiles() const;
1718
QUrl projectPath() const;
19+
QStringList extensions() const;
1820

1921
signals:
2022
void qmlFilesChanged();
23+
void extensionsChanged();
2124

2225
public slots:
2326
void update();
2427

28+
void setExtensions(const QStringList &extensions);
29+
2530
private:
2631
QStringList m_qmlFiles;
2732
QUrl m_projectPath;
33+
QStringList m_extensions;
2834

2935
void updateFiles();
3036
};

0 commit comments

Comments
 (0)