Commit bafe4468 authored by Kai Koehne's avatar Kai Koehne
Browse files

Add support for JavaScriptFiles and ImageFiles elements to .qmlproject

parent 269506c9
......@@ -46,8 +46,11 @@ void FileFilterBaseItem::setFilter(const QString &filter)
if (filter == m_filter)
return;
m_filter = filter;
m_regex.setPattern(m_filter);
m_regex.setPatternSyntax(QRegExp::Wildcard);
m_regExpList.clear();
foreach (const QString &pattern, filter.split(QLatin1Char(';'))) {
m_regExpList << QRegExp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard);
}
emit filterChanged();
updateFileList();
......@@ -113,7 +116,7 @@ void FileFilterBaseItem::updateFileList()
newFiles << QDir(projectDir).absoluteFilePath(explicitPath);
}
}
if (m_regex.isValid() && m_explicitFiles.isEmpty())
if (!m_regExpList.isEmpty() && m_explicitFiles.isEmpty())
newFiles += filesInSubTree(QDir(m_defaultDir), QDir(projectDir), &dirsToBeWatched);
if (newFiles != m_files) {
......@@ -149,8 +152,12 @@ QSet<QString> FileFilterBaseItem::filesInSubTree(const QDir &rootDir, const QDir
parsedDirs->insert(dir.absolutePath());
foreach (const QFileInfo &file, dir.entryInfoList(QDir::Files)) {
if (m_regex.exactMatch(file.fileName())) {
fileSet.insert(file.absoluteFilePath());
const QString fileName = file.fileName();
foreach (const QRegExp &filter, m_regExpList) {
if (filter.exactMatch(fileName)) {
fileSet.insert(file.absoluteFilePath());
break;
}
}
}
......
......@@ -58,7 +58,7 @@ private:
QString m_defaultDir;
QString m_filter;
QRegExp m_regex;
QList<QRegExp> m_regExpList;
bool m_recursive;
QSet<QString> m_explicitFiles;
......
......@@ -127,11 +127,23 @@ Core::GeneratedFiles QmlNewProjectWizard::generateFiles(const QWizard *w,
QTextStream out(&projectContents);
out
//: Comment added to generated .qmlproject file
<< "// " << tr("File generated by QtCreator", "qmlproject Template") << endl
<< endl
<< "import QmlProject 1.0" << endl
<< endl
<< "Project {" << endl
//: Comment added to generated .qmlproject file
<< " // " << tr("Scan current directory for .qml, .js, and image files", "qmlproject Template") << endl
<< " QmlFiles {" << endl
<< " directory: \".\"" << endl
<< " }" << endl
<< " JavaScriptFiles {" << endl
<< " directory: \".\"" << endl
<< " }" << endl
<< " ImageFiles {" << endl
<< " directory: \".\"" << endl
<< " }" << endl
<< "}" << endl;
}
Core::GeneratedFile generatedCreatorFile(creatorFileName);
......
......@@ -41,7 +41,7 @@ using namespace QmlProjectManager;
using namespace QmlProjectManager::Internal;
QmlProjectNode::QmlProjectNode(QmlProject *project, Core::IFile *projectFile)
: ProjectExplorer::ProjectNode(QFileInfo(projectFile->fileName()).absolutePath()),
: ProjectExplorer::ProjectNode(QFileInfo(projectFile->fileName()).absoluteFilePath()),
m_project(project),
m_projectFile(projectFile)
{
......@@ -145,6 +145,7 @@ ProjectExplorer::FolderNode *QmlProjectNode::findOrCreateFolderByName(const QStr
FolderNode *parent = findOrCreateFolderByName(components, end - 1);
if (! parent)
parent = this;
addFolderNodes(QList<FolderNode*>() << folder, parent);
return folder;
......
......@@ -133,12 +133,25 @@ Core::GeneratedFiles QmlProjectWizard::generateFiles(const QWizard *w,
QTextStream out(&projectContents);
out
//: Comment added to generated .qmlproject file
<< "// " << tr("File generated by QtCreator", "qmlproject Template") << endl
<< endl
<< "import QmlProject 1.0" << endl
<< endl
<< "Project {" << endl
<< " // " << tr("Scan current directory and subdirectories for .qml, .js, and image files", "qmlproject Template") << endl
<< " QmlFiles {" << endl
<< " directory: \".\"" << endl
<< " recursive: true" << endl
<< " }" << endl
<< " JavaScriptFiles {" << endl
<< " directory: \".\"" << endl
<< " recursive: true" << endl
<< " }" << endl
<< " ImageFiles {" << endl
<< " directory: \".\"" << endl
<< " recursive: true" << endl
<< " }" << endl
<< "}" << endl;
}
Core::GeneratedFile generatedCreatorFile(creatorFileName);
......
......@@ -14,7 +14,7 @@ public:
TestProject();
private slots:
void testQmlFileFilter();
void testFileFilter();
};
TestProject::TestProject()
......@@ -24,7 +24,7 @@ TestProject::TestProject()
QString testDataDir = QLatin1String(SRCDIR "/data");
void TestProject::testQmlFileFilter()
void TestProject::testFileFilter()
{
//
// search for qml files in local directory
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment