QmlProject files: Make "paths" property an array

Instead of letting the list of files being a (comma separated) string
it's now a full JavaScript array. E.g.

  paths: ["file1", "file2"]

This unifies it with e.g. the libraryPaths property
This commit is contained in:
Kai Koehne
2010-02-22 13:45:35 +01:00
parent 5e5192ad57
commit 481d7cd6db
3 changed files with 11 additions and 15 deletions

View File

@@ -69,18 +69,14 @@ void FileFilterBaseItem::setRecursive(bool recursive)
updateFileList();
}
QString FileFilterBaseItem::pathsProperty() const
QStringList FileFilterBaseItem::pathsProperty() const
{
return QStringList(m_explicitFiles.toList()).join(",");
return m_explicitFiles;
}
void FileFilterBaseItem::setPathsProperty(const QString &path)
void FileFilterBaseItem::setPathsProperty(const QStringList &path)
{
// we support listening paths both in an array, and in one string
m_explicitFiles.clear();
foreach (const QString &subpath, path.split(QLatin1Char(','), QString::SkipEmptyParts)) {
m_explicitFiles += subpath.trimmed();
}
m_explicitFiles = path;
updateFileList();
}

View File

@@ -16,7 +16,7 @@ class FileFilterBaseItem : public QmlProjectContentItem {
Q_PROPERTY(QString directory READ directory WRITE setDirectory NOTIFY directoryChanged)
Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged)
Q_PROPERTY(QString paths READ pathsProperty WRITE setPathsProperty NOTIFY pathsPropertyChanged)
Q_PROPERTY(QStringList paths READ pathsProperty WRITE setPathsProperty NOTIFY pathsPropertyChanged)
Q_PROPERTY(QStringList files READ files NOTIFY filesChanged DESIGNABLE false)
@@ -34,8 +34,8 @@ public:
bool recursive() const;
void setRecursive(bool recursive);
QString pathsProperty() const;
void setPathsProperty(const QString &path);
QStringList pathsProperty() const;
void setPathsProperty(const QStringList &paths);
virtual QStringList files() const;
bool matchesFile(const QString &filePath) const;
@@ -43,7 +43,7 @@ public:
signals:
void directoryChanged();
void recursiveChanged();
void pathsPropertyChanged();
void pathsChanged();
void filesChanged();
void filterChanged();
@@ -62,7 +62,7 @@ private:
QString m_filter;
QList<QRegExp> m_regExpList;
bool m_recursive;
QSet<QString> m_explicitFiles;
QStringList m_explicitFiles;
QFileSystemWatcher m_fsWatcher;

View File

@@ -153,8 +153,8 @@ void TestProject::testFileFilter()
"import QmlProject 1.0\n"
"Project {\n"
" QmlFiles {\n"
" paths: \"file1.qml,\n"
"file2.qml\"\n"
" paths: [ \"file1.qml\",\n"
"\"file2.qml\" ]\n"
" }\n"
"}\n");