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

Adjust .qmlproject files generated by wizards to new format

parent 5c16f706
......@@ -103,26 +103,40 @@ Core::GeneratedFiles QmlNewProjectWizard::generateFiles(const QWizard *w,
QLatin1String("qml"));
QString contents;
QTextStream out(&contents);
out
<< "import Qt 4.6" << endl
<< endl
<< "Rectangle {" << endl
<< " width: 200" << endl
<< " height: 200" << endl
<< " Text {" << endl
<< " x: 66" << endl
<< " y: 93" << endl
<< " text: \"Hello World\"" << endl
<< " }" << endl
<< "}" << endl;
{
QTextStream out(&contents);
out
<< "import Qt 4.6" << endl
<< endl
<< "Rectangle {" << endl
<< " width: 200" << endl
<< " height: 200" << endl
<< " Text {" << endl
<< " x: 66" << endl
<< " y: 93" << endl
<< " text: \"Hello World\"" << endl
<< " }" << endl
<< "}" << endl;
}
Core::GeneratedFile generatedMainFile(mainFileName);
generatedMainFile.setContents(contents);
QString projectContents;
{
QTextStream out(&projectContents);
out
<< "import QmlProject 1.0" << endl
<< "Project {" << endl
<< " QmlFiles {" << endl
<< " directory: \".\"" << endl
<< " }" << endl
<< "}" << endl;
}
Core::GeneratedFile generatedCreatorFile(creatorFileName);
generatedCreatorFile.setContents(projectName + QLatin1String(".qml\n"));
generatedCreatorFile.setContents(projectContents);
Core::GeneratedFiles files;
files.append(generatedMainFile);
......
......@@ -117,48 +117,6 @@ QWizard *QmlProjectWizard::createWizardDialog(QWidget *parent,
return wizard;
}
void QmlProjectWizard::getFileList(const QDir &dir, const QString &projectRoot,
const QStringList &suffixes,
QStringList *files, QStringList *paths) const
{
const QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files |
QDir::Dirs |
QDir::NoDotAndDotDot |
QDir::NoSymLinks);
foreach (const QFileInfo &fileInfo, fileInfoList) {
QString filePath = fileInfo.absoluteFilePath();
filePath = filePath.mid(projectRoot.length() + 1);
if (fileInfo.isDir() && isValidDir(fileInfo)) {
getFileList(QDir(fileInfo.absoluteFilePath()), projectRoot,
suffixes, files, paths);
if (! paths->contains(filePath))
paths->append(filePath);
}
else if (suffixes.contains(fileInfo.suffix()))
files->append(filePath);
}
}
bool QmlProjectWizard::isValidDir(const QFileInfo &fileInfo) const
{
const QString fileName = fileInfo.fileName();
const QString suffix = fileInfo.suffix();
if (fileName.startsWith(QLatin1Char('.')))
return false;
else if (fileName == QLatin1String("CVS"))
return false;
// ### user include/exclude
return true;
}
Core::GeneratedFiles QmlProjectWizard::generateFiles(const QWizard *w,
QString *errorMessage) const
{
......@@ -170,16 +128,21 @@ Core::GeneratedFiles QmlProjectWizard::generateFiles(const QWizard *w,
const QString projectName = wizard->projectName();
const QString creatorFileName = QFileInfo(dir, projectName + QLatin1String(".qmlproject")).absoluteFilePath();
Core::ICore *core = Core::ICore::instance();
Core::MimeDatabase *mimeDatabase = core->mimeDatabase();
const QStringList suffixes = mimeDatabase->suffixes();
QStringList sources, paths;
getFileList(dir, projectPath, suffixes, &sources, &paths);
QString projectContents;
{
QTextStream out(&projectContents);
out
<< "import QmlProject 1.0" << endl
<< "Project {" << endl
<< " QmlFiles {" << endl
<< " directory: \".\"" << endl
<< " recursive: true" << endl
<< " }" << endl
<< "}" << endl;
}
Core::GeneratedFile generatedCreatorFile(creatorFileName);
generatedCreatorFile.setContents(sources.join(QLatin1String("\n")));
generatedCreatorFile.setContents(projectContents);
Core::GeneratedFiles files;
files.append(generatedCreatorFile);
......
......@@ -84,13 +84,6 @@ protected:
QString *errorMessage) const;
virtual bool postGenerateFiles(const Core::GeneratedFiles &l, QString *errorMessage);
bool isValidDir(const QFileInfo &fileInfo) const;
void getFileList(const QDir &dir, const QString &projectRoot,
const QStringList &suffixes,
QStringList *files,
QStringList *paths) const;
};
} // end of namespace Internal
......
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