Commit 83638838 authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Merge touchnavigation code into html5applicationviewer.cpp

The touchnavigation code had been splitted for easier development.
But we do not want the wizard to generate those many files. The
Wizard takes care of that and merges all into one.
parent 44590611
......@@ -171,6 +171,76 @@ Core::GeneratedFiles Html5App::generateFiles(QString *errorMessage) const
}
#endif // CREATORLESSTEST
QByteArray Html5App::appViewerCppFileCode(QString *errorMessage) const
{
static const char* touchNavigavigationFiles[] = {
"webtouchphysicsinterface.h",
"webtouchphysics.h",
"webtouchevent.h",
"webtouchscroller.h",
"webtouchnavigation.h",
"webnavigation.h",
"navigationcontroller.h",
"webtouchphysicsinterface.cpp",
"webtouchphysics.cpp",
"webtouchevent.cpp",
"webtouchscroller.cpp",
"webtouchnavigation.cpp",
"webnavigation.cpp",
"navigationcontroller.cpp",
};
static const QString touchNavigavigationDir =
originsRoot() + appViewerOriginsSubDir + QLatin1String("touchnavigation/");
QByteArray touchNavigavigationCode;
for (int i = 0; i < sizeof(touchNavigavigationFiles) / sizeof(touchNavigavigationFiles[0]); ++i) {
QFile touchNavigavigationFile(touchNavigavigationDir + QLatin1String(touchNavigavigationFiles[i]));
if (!touchNavigavigationFile.open(QIODevice::ReadOnly)) {
if (errorMessage)
*errorMessage = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp",
"Could not open template file '%1'.").arg(touchNavigavigationFiles[i]);
return QByteArray();
}
QTextStream touchNavigavigationFileIn(&touchNavigavigationFile);
QString line;
while (!(line = touchNavigavigationFileIn.readLine()).isNull()) {
if (line.startsWith(QLatin1String("#include")) ||
(line.startsWith(QLatin1String("#ifndef"))
|| line.startsWith(QLatin1String("#define"))
|| line.startsWith(QLatin1String("#endif")))
&& line.endsWith(QLatin1String("_H")))
continue;
touchNavigavigationCode.append(line + QLatin1Char('\n'));
}
}
QFile appViewerCppFile(path(AppViewerCppOrigin));
if (!appViewerCppFile.open(QIODevice::ReadOnly)) {
if (errorMessage)
*errorMessage = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp",
"Could not open template file '%1'.").arg(path(AppViewerCppOrigin));
return QByteArray();
}
QTextStream in(&appViewerCppFile);
QByteArray appViewerCppCode;
bool touchNavigavigationCodeInserted = false;
QString line;
while (!(line = in.readLine()).isNull()) {
if (!touchNavigavigationCodeInserted && line == QLatin1String("#ifdef TOUCH_OPTIMIZED_NAVIGATION")) {
appViewerCppCode.append(line + QLatin1Char('\n'));
while (!(line = in.readLine()).isNull()
&& !line.contains(QLatin1String("#endif // TOUCH_OPTIMIZED_NAVIGATION")))
{
if (!line.startsWith(QLatin1String("#include \"")))
appViewerCppCode.append(line + QLatin1Char('\n'));
}
appViewerCppCode.append(touchNavigavigationCode);
touchNavigavigationCodeInserted = true;
}
appViewerCppCode.append(line + QLatin1Char('\n'));
}
return appViewerCppCode;
}
QByteArray Html5App::generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const
{
......@@ -186,7 +256,7 @@ QByteArray Html5App::generateFileExtended(int fileType,
*versionAndCheckSum = true;
break;
case Html5AppGeneratedFileInfo::AppViewerCppFile:
data = readBlob(path(AppViewerCppOrigin), errorMessage);
data = appViewerCppFileCode(errorMessage);
*versionAndCheckSum = true;
break;
case Html5AppGeneratedFileInfo::AppViewerHFile:
......
......@@ -109,6 +109,7 @@ private:
bool &commentOutNextLine) const;
QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const;
QList<DeploymentFolder> deploymentFolders() const;
QByteArray appViewerCppFileCode(QString *errorMessage) const;
QFileInfo m_indexHtmlFile;
Mode m_mainHtmlMode;
......
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