Commit 4413f9d6 authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Refactoring. Unduplicating code.

The loop to generate the "DEPLOYMENTFOLDERS" part in the main
.pro file is now in the base class AbstractMobileApp.
parent 2899613b
......@@ -257,6 +257,28 @@ QByteArray AbstractMobileApp::generateProFile(QString *errorMessage) const
} else if (line.contains(QLatin1String("# NETWORKACCESS"))
&& !networkEnabled()) {
commentOutNextLine = true;
} else if (line.contains(QLatin1String("# DEPLOYMENTFOLDERS"))) {
// Eat lines
QString nextLine;
while (!(nextLine = in.readLine()).isNull()
&& !nextLine.contains(QLatin1String("# DEPLOYMENTFOLDERS_END")))
{ }
if (nextLine.isNull())
continue;
int foldersCount = 0;
QStringList folders;
foreach (const DeploymentFolder &folder, deploymentFolders()) {
foldersCount++;
const QString folderName =
QString::fromLatin1("folder_%1").arg(foldersCount, 2, 10, QLatin1Char('0'));
out << folderName << ".source = " << folder.first << endl;
if (!folder.second.isEmpty())
out << folderName << ".target = " << folder.second << endl;
folders.append(folderName);
}
if (foldersCount > 0)
out << "DEPLOYMENTFOLDERS = " << folders.join(QLatin1String(" ")) << endl;
} else {
handleCurrentProFileTemplateLine(line, in, out, commentOutNextLine);
}
......
......@@ -35,6 +35,7 @@
#define ABSTRACTMOBILEAPP_H
#include <QtCore/QFileInfo>
#include <QtCore/QPair>
#ifndef CREATORLESSTEST
#include <coreplugin/basefilewizard.h>
......@@ -67,6 +68,8 @@ struct AbstractGeneratedFileInfo
quint16 statedChecksum; // The checksum in the file header
};
typedef QPair<QString, QString> DeploymentFolder; // QPair<.source, .target>
class AbstractMobileApp : public QObject
{
Q_OBJECT
......@@ -163,6 +166,7 @@ private:
QTextStream &proFileTemplate, QTextStream &proFile,
bool &commentOutNextLine) const = 0;
virtual QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const = 0;
virtual QList<DeploymentFolder> deploymentFolders() const = 0;
QString m_projectName;
QFileInfo m_projectPath;
......
......@@ -124,20 +124,7 @@ void Html5App::handleCurrentProFileTemplateLine(const QString &line,
bool &commentOutNextLine) const
{
Q_UNUSED(commentOutNextLine)
if (line.contains(QLatin1String("# DEPLOYMENTFOLDERS"))) {
// Eat lines
QString nextLine;
while (!(nextLine = proFileTemplate.readLine()).isNull()
&& !nextLine.contains(QLatin1String("# DEPLOYMENTFOLDERS_END")))
{ }
if (nextLine.isNull())
return;
QStringList folders;
proFile << "folder_01.source = " << path(HtmlDirProFileRelative) << endl;
proFile << "folder_01.target = ." << endl;
folders.append(QLatin1String("folder_01"));
proFile << "DEPLOYMENTFOLDERS = " << folders.join(QLatin1String(" ")) << endl;
} else if (line.contains(QLatin1String("# INCLUDE_DEPLOYMENT_PRI"))) {
if (line.contains(QLatin1String("# INCLUDE_DEPLOYMENT_PRI"))) {
proFileTemplate.readLine(); // eats 'include(deployment.pri)'
}
}
......@@ -225,6 +212,13 @@ QList<AbstractGeneratedFileInfo> Html5App::updateableFiles(const QString &mainPr
return result;
}
QList<DeploymentFolder> Html5App::deploymentFolders() const
{
QList<DeploymentFolder> result;
result.append(DeploymentFolder(path(HtmlDirProFileRelative), QLatin1String(".")));
return result;
}
const int Html5App::StubVersion = 10;
} // namespace Internal
......
......@@ -101,6 +101,7 @@ private:
QTextStream &proFileTemplate, QTextStream &proFile,
bool &commentOutNextLine) const;
QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const;
QList<DeploymentFolder> deploymentFolders() const;
QFileInfo m_indexHtmlFile;
};
......
......@@ -148,6 +148,12 @@ QList<AbstractGeneratedFileInfo> MobileApp::updateableFiles(const QString &mainP
return QList<AbstractGeneratedFileInfo>(); // Nothing to update, here
}
QList<DeploymentFolder> MobileApp::deploymentFolders() const
{
QList<DeploymentFolder> result;
return result;
}
const int MobileApp::StubVersion = 2;
} // namespace Internal
......
......@@ -81,6 +81,7 @@ private:
QTextStream &proFileTemplate, QTextStream &proFile,
bool &commentOutNextLine) const;
QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const;
QList<DeploymentFolder> deploymentFolders() const;
};
} // namespace Internal
......
......@@ -219,31 +219,7 @@ void QtQuickApp::handleCurrentProFileTemplateLine(const QString &line,
QTextStream &proFileTemplate, QTextStream &proFile,
bool &commentOutNextLine) const
{
if (line.contains(QLatin1String("# DEPLOYMENTFOLDERS"))) {
// Eat lines
QString nextLine;
while (!(nextLine = proFileTemplate.readLine()).isNull()
&& !nextLine.contains(QLatin1String("# DEPLOYMENTFOLDERS_END")))
{ }
if (nextLine.isNull())
return;
QStringList folders;
proFile << "folder_01.source = " << path(QmlDirProFileRelative) << endl;
proFile << "folder_01.target = qml" << endl;
folders.append(QLatin1String("folder_01"));
int foldersCount = 1;
foreach (const QmlModule *module, m_modules) {
if (module->isExternal) {
foldersCount ++;
const QString folder =
QString::fromLatin1("folder_%1").arg(foldersCount, 2, 10, QLatin1Char('0'));
folders.append(folder);
proFile << folder << ".source = " << module->path(QmlModule::ContentDir) << endl;
proFile << folder << ".target = " << module->path(QmlModule::DeployedContentBase) << endl;
}
}
proFile << "DEPLOYMENTFOLDERS = " << folders.join(QLatin1String(" ")) << endl;
} else if (line.contains(QLatin1String("# QMLJSDEBUGGER"))) {
if (line.contains(QLatin1String("# QMLJSDEBUGGER"))) {
// ### disabled for now; figure out the private headers problem first.
//commentOutNextLine = true;
Q_UNUSED(commentOutNextLine)
......@@ -432,6 +408,16 @@ QList<AbstractGeneratedFileInfo> QtQuickApp::updateableFiles(const QString &main
return result;
}
QList<DeploymentFolder> QtQuickApp::deploymentFolders() const
{
QList<DeploymentFolder> result;
result.append(DeploymentFolder(path(QmlDirProFileRelative), QLatin1String("qml")));
foreach (const QmlModule *module, m_modules)
if (module->isExternal)
result.append(DeploymentFolder(module->path(QmlModule::ContentDir), module->path(QmlModule::DeployedContentBase)));
return result;
}
const int QtQuickApp::StubVersion = 10;
} // namespace Internal
......
......@@ -136,6 +136,7 @@ private:
QTextStream &proFileTemplate, QTextStream &proFile,
bool &commentOutNextLine) const;
QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const;
QList<DeploymentFolder> deploymentFolders() const;
bool addExternalModule(const QString &uri, const QFileInfo &dir,
const QFileInfo &contentDir);
......
Markdown is supported
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