forked from qt-creator/qt-creator
Add support for 'paths' property in QmlFiles element
This commit is contained in:
@@ -65,6 +65,21 @@ void FileFilterBaseItem::setRecursive(bool recursive)
|
||||
updateFileList();
|
||||
}
|
||||
|
||||
QString FileFilterBaseItem::pathsProperty() const
|
||||
{
|
||||
return QStringList(m_explicitFiles.toList()).join(",");
|
||||
}
|
||||
|
||||
void FileFilterBaseItem::setPathsProperty(const QString &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();
|
||||
}
|
||||
updateFileList();
|
||||
}
|
||||
|
||||
QStringList FileFilterBaseItem::files() const
|
||||
{
|
||||
return m_files.toList();
|
||||
@@ -89,7 +104,16 @@ void FileFilterBaseItem::updateFileList()
|
||||
return;
|
||||
|
||||
QSet<QString> dirsToBeWatched;
|
||||
const QSet<QString> newFiles = filesInSubTree(QDir(m_defaultDir), QDir(projectDir), &dirsToBeWatched);
|
||||
QSet<QString> newFiles;
|
||||
foreach (const QString &explicitPath, m_explicitFiles) {
|
||||
if (QFileInfo(explicitPath).isAbsolute()) {
|
||||
newFiles << explicitPath;
|
||||
} else {
|
||||
newFiles << QDir(projectDir).absoluteFilePath(explicitPath);
|
||||
}
|
||||
}
|
||||
if (m_regex.isValid() && m_explicitFiles.isEmpty())
|
||||
newFiles += filesInSubTree(QDir(m_defaultDir), QDir(projectDir), &dirsToBeWatched);
|
||||
|
||||
if (newFiles != m_files) {
|
||||
// update watched files
|
||||
|
||||
@@ -16,8 +16,9 @@ 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(QList<QString> files READ files NOTIFY filesChanged)
|
||||
Q_PROPERTY(QStringList files READ files NOTIFY filesChanged DESIGNABLE false)
|
||||
|
||||
public:
|
||||
FileFilterBaseItem(QObject *parent = 0);
|
||||
@@ -33,13 +34,17 @@ public:
|
||||
bool recursive() const;
|
||||
void setRecursive(bool recursive);
|
||||
|
||||
QString pathsProperty() const;
|
||||
void setPathsProperty(const QString &path);
|
||||
|
||||
virtual QStringList files() const;
|
||||
|
||||
signals:
|
||||
void directoryChanged();
|
||||
void recursiveChanged();
|
||||
void filterChanged();
|
||||
void pathsPropertyChanged();
|
||||
void filesChanged();
|
||||
void filterChanged();
|
||||
|
||||
private slots:
|
||||
void updateFileList();
|
||||
@@ -55,6 +60,7 @@ private:
|
||||
QString m_filter;
|
||||
QRegExp m_regex;
|
||||
bool m_recursive;
|
||||
QSet<QString> m_explicitFiles;
|
||||
|
||||
QFileSystemWatcher m_fsWatcher;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user