forked from qt-creator/qt-creator
AndroidManager: Move private static functions to implementation
Change-Id: I245af5cc77360aa70838153e0fd8eb15ffe659d8 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -76,6 +76,35 @@ namespace Android {
|
|||||||
|
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
|
||||||
|
class Library
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Library()
|
||||||
|
{ level = -1; }
|
||||||
|
int level;
|
||||||
|
QStringList dependencies;
|
||||||
|
QString name;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QMap<QString, Library> LibrariesMap;
|
||||||
|
|
||||||
|
static bool openXmlFile(QDomDocument &doc, const Utils::FileName &fileName);
|
||||||
|
static bool saveXmlFile(QDomDocument &doc, const Utils::FileName &fileName);
|
||||||
|
static bool openManifest(ProjectExplorer::Target *target, QDomDocument &doc);
|
||||||
|
static bool saveManifest(ProjectExplorer::Target *target, QDomDocument &doc);
|
||||||
|
static QStringList libsXml(ProjectExplorer::Target *target, const QString &tag);
|
||||||
|
static bool setLibsXml(ProjectExplorer::Target *target, const QStringList &libs, const QString &tag);
|
||||||
|
|
||||||
|
enum ItemType
|
||||||
|
{
|
||||||
|
Lib,
|
||||||
|
Jar,
|
||||||
|
BundledFile,
|
||||||
|
BundledJar
|
||||||
|
};
|
||||||
|
static QString loadLocal(ProjectExplorer::Target *target, int apiLevel, ItemType item, const QString &attribute=QLatin1String("file"));
|
||||||
|
|
||||||
|
|
||||||
bool AndroidManager::supportsAndroid(const ProjectExplorer::Kit *kit)
|
bool AndroidManager::supportsAndroid(const ProjectExplorer::Kit *kit)
|
||||||
{
|
{
|
||||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
||||||
@@ -288,22 +317,22 @@ QStringList AndroidManager::prebundledLibs(ProjectExplorer::Target *target)
|
|||||||
return libsXml(target, QLatin1String("bundled_libs"));
|
return libsXml(target, QLatin1String("bundled_libs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManager::openLibsXml(ProjectExplorer::Target *target, QDomDocument &doc)
|
static bool openLibsXml(ProjectExplorer::Target *target, QDomDocument &doc)
|
||||||
{
|
{
|
||||||
return openXmlFile(doc, libsPath(target));
|
return openXmlFile(doc, AndroidManager::libsPath(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManager::saveLibsXml(ProjectExplorer::Target *target, QDomDocument &doc)
|
static bool saveLibsXml(ProjectExplorer::Target *target, QDomDocument &doc)
|
||||||
{
|
{
|
||||||
return saveXmlFile(doc, libsPath(target));
|
return saveXmlFile(doc, AndroidManager::libsPath(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManager::raiseError(const QString &reason)
|
static void raiseError(const QString &reason)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(0, tr("Error creating Android templates."), reason);
|
QMessageBox::critical(0, AndroidManager::tr("Error creating Android templates."), reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AndroidManager::loadLocal(ProjectExplorer::Target *target, int apiLevel, ItemType item, const QString &attribute)
|
static QString loadLocal(ProjectExplorer::Target *target, int apiLevel, ItemType item, const QString &attribute)
|
||||||
{
|
{
|
||||||
QString itemType;
|
QString itemType;
|
||||||
if (item == Lib)
|
if (item == Lib)
|
||||||
@@ -315,12 +344,12 @@ QString AndroidManager::loadLocal(ProjectExplorer::Target *target, int apiLevel,
|
|||||||
|
|
||||||
QString localLibs;
|
QString localLibs;
|
||||||
|
|
||||||
QDir rulesFilesDir(localLibsRulesFilePath(target).toString());
|
QDir rulesFilesDir(AndroidManager::localLibsRulesFilePath(target).toString());
|
||||||
if (!rulesFilesDir.exists())
|
if (!rulesFilesDir.exists())
|
||||||
return localLibs;
|
return localLibs;
|
||||||
|
|
||||||
QStringList libs;
|
QStringList libs;
|
||||||
libs << qtLibs(target) << prebundledLibs(target);
|
libs << AndroidManager::qtLibs(target) << AndroidManager::prebundledLibs(target);
|
||||||
|
|
||||||
QFileInfoList rulesFiles = rulesFilesDir.entryInfoList(QStringList() << QLatin1String("*.xml"),
|
QFileInfoList rulesFiles = rulesFilesDir.entryInfoList(QStringList() << QLatin1String("*.xml"),
|
||||||
QDir::Files | QDir::Readable);
|
QDir::Files | QDir::Readable);
|
||||||
@@ -402,41 +431,41 @@ QString AndroidManager::loadLocal(ProjectExplorer::Target *target, int apiLevel,
|
|||||||
return localLibs;
|
return localLibs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManager::openXmlFile(QDomDocument &doc, const Utils::FileName &fileName)
|
static bool openXmlFile(QDomDocument &doc, const Utils::FileName &fileName)
|
||||||
{
|
{
|
||||||
QFile f(fileName.toString());
|
QFile f(fileName.toString());
|
||||||
if (!f.open(QIODevice::ReadOnly))
|
if (!f.open(QIODevice::ReadOnly))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!doc.setContent(f.readAll())) {
|
if (!doc.setContent(f.readAll())) {
|
||||||
raiseError(tr("Cannot parse \"%1\".").arg(fileName.toUserOutput()));
|
raiseError(AndroidManager::tr("Cannot parse \"%1\".").arg(fileName.toUserOutput()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManager::saveXmlFile(QDomDocument &doc, const Utils::FileName &fileName)
|
static bool saveXmlFile(QDomDocument &doc, const Utils::FileName &fileName)
|
||||||
{
|
{
|
||||||
QFile f(fileName.toString());
|
QFile f(fileName.toString());
|
||||||
if (!f.open(QIODevice::WriteOnly)) {
|
if (!f.open(QIODevice::WriteOnly)) {
|
||||||
raiseError(tr("Cannot open \"%1\".").arg(fileName.toUserOutput()));
|
raiseError(AndroidManager::tr("Cannot open \"%1\".").arg(fileName.toUserOutput()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return f.write(doc.toByteArray(4)) >= 0;
|
return f.write(doc.toByteArray(4)) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManager::openManifest(ProjectExplorer::Target *target, QDomDocument &doc)
|
static bool openManifest(ProjectExplorer::Target *target, QDomDocument &doc)
|
||||||
{
|
{
|
||||||
return openXmlFile(doc, manifestPath(target));
|
return openXmlFile(doc, AndroidManager::manifestPath(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManager::saveManifest(ProjectExplorer::Target *target, QDomDocument &doc)
|
static bool saveManifest(ProjectExplorer::Target *target, QDomDocument &doc)
|
||||||
{
|
{
|
||||||
Core::FileChangeBlocker blocker(manifestPath(target).toString());
|
Core::FileChangeBlocker blocker(AndroidManager::manifestPath(target).toString());
|
||||||
return saveXmlFile(doc, manifestPath(target));
|
return saveXmlFile(doc, AndroidManager::manifestPath(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AndroidManager::libsXml(ProjectExplorer::Target *target, const QString &tag)
|
static QStringList libsXml(ProjectExplorer::Target *target, const QString &tag)
|
||||||
{
|
{
|
||||||
QStringList libs;
|
QStringList libs;
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
@@ -457,7 +486,7 @@ QStringList AndroidManager::libsXml(ProjectExplorer::Target *target, const QStri
|
|||||||
return libs;
|
return libs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidManager::setLibsXml(ProjectExplorer::Target *target, const QStringList &libs, const QString &tag)
|
static bool setLibsXml(ProjectExplorer::Target *target, const QStringList &libs, const QString &tag)
|
||||||
{
|
{
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
if (!openLibsXml(target, doc))
|
if (!openLibsXml(target, doc))
|
||||||
@@ -482,7 +511,7 @@ bool AndroidManager::setLibsXml(ProjectExplorer::Target *target, const QStringLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AndroidManager::dependencies(const Utils::FileName &readelfPath, const QString &lib)
|
static QStringList dependencies(const Utils::FileName &readelfPath, const QString &lib)
|
||||||
{
|
{
|
||||||
QStringList libs;
|
QStringList libs;
|
||||||
|
|
||||||
@@ -504,7 +533,7 @@ QStringList AndroidManager::dependencies(const Utils::FileName &readelfPath, con
|
|||||||
return libs;
|
return libs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AndroidManager::setLibraryLevel(const QString &library, LibrariesMap &mapLibs)
|
static int setLibraryLevel(const QString &library, LibrariesMap &mapLibs)
|
||||||
{
|
{
|
||||||
int maxlevel = mapLibs[library].level;
|
int maxlevel = mapLibs[library].level;
|
||||||
if (maxlevel > 0)
|
if (maxlevel > 0)
|
||||||
@@ -648,7 +677,7 @@ bool AndroidManager::checkForQt51Files(Utils::FileName fileName)
|
|||||||
if (!fileName.toFileInfo().exists())
|
if (!fileName.toFileInfo().exists())
|
||||||
return false;
|
return false;
|
||||||
QDomDocument dstVersionDoc;
|
QDomDocument dstVersionDoc;
|
||||||
if (!AndroidManager::openXmlFile(dstVersionDoc, fileName))
|
if (!openXmlFile(dstVersionDoc, fileName))
|
||||||
return false;
|
return false;
|
||||||
return dstVersionDoc.documentElement().attribute(QLatin1String("value")).toDouble() < 5.2;
|
return dstVersionDoc.documentElement().attribute(QLatin1String("value")).toDouble() < 5.2;
|
||||||
}
|
}
|
||||||
|
@@ -37,10 +37,6 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QDomDocument;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class Kit;
|
class Kit;
|
||||||
class Target;
|
class Target;
|
||||||
@@ -90,17 +86,6 @@ public:
|
|||||||
static QPair<int, int> apiLevelRange();
|
static QPair<int, int> apiLevelRange();
|
||||||
static QString androidNameForApiLevel(int x);
|
static QString androidNameForApiLevel(int x);
|
||||||
|
|
||||||
class Library
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Library()
|
|
||||||
{ level = -1; }
|
|
||||||
int level;
|
|
||||||
QStringList dependencies;
|
|
||||||
QString name;
|
|
||||||
};
|
|
||||||
typedef QMap<QString, Library> LibrariesMap;
|
|
||||||
|
|
||||||
static QStringList qtLibs(ProjectExplorer::Target *target);
|
static QStringList qtLibs(ProjectExplorer::Target *target);
|
||||||
static QStringList prebundledLibs(ProjectExplorer::Target *target);
|
static QStringList prebundledLibs(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
@@ -111,30 +96,6 @@ public:
|
|||||||
static bool checkCertificatePassword(const QString &keystorePath, const QString &keystorePasswd, const QString &alias, const QString &certificatePasswd);
|
static bool checkCertificatePassword(const QString &keystorePath, const QString &keystorePasswd, const QString &alias, const QString &certificatePasswd);
|
||||||
static bool checkForQt51Files(Utils::FileName fileName);
|
static bool checkForQt51Files(Utils::FileName fileName);
|
||||||
static AndroidQtSupport *androidQtSupport(ProjectExplorer::Target *target);
|
static AndroidQtSupport *androidQtSupport(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
private:
|
|
||||||
static void raiseError(const QString &reason);
|
|
||||||
static bool openXmlFile(QDomDocument &doc, const Utils::FileName &fileName);
|
|
||||||
static bool saveXmlFile(QDomDocument &doc, const Utils::FileName &fileName);
|
|
||||||
static bool openManifest(ProjectExplorer::Target *target, QDomDocument &doc);
|
|
||||||
static bool saveManifest(ProjectExplorer::Target *target, QDomDocument &doc);
|
|
||||||
static bool openLibsXml(ProjectExplorer::Target *target, QDomDocument &doc);
|
|
||||||
static bool saveLibsXml(ProjectExplorer::Target *target, QDomDocument &doc);
|
|
||||||
static QStringList libsXml(ProjectExplorer::Target *target, const QString &tag);
|
|
||||||
static bool setLibsXml(ProjectExplorer::Target *target, const QStringList &libs, const QString &tag);
|
|
||||||
|
|
||||||
enum ItemType
|
|
||||||
{
|
|
||||||
Lib,
|
|
||||||
Jar,
|
|
||||||
BundledFile,
|
|
||||||
BundledJar
|
|
||||||
};
|
|
||||||
static QString loadLocal(ProjectExplorer::Target *target, int apiLevel, ItemType item, const QString &attribute=QLatin1String("file"));
|
|
||||||
|
|
||||||
static QStringList dependencies(const Utils::FileName &readelfPath, const QString &lib);
|
|
||||||
static int setLibraryLevel(const QString &library, LibrariesMap &mapLibs);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Android
|
} // namespace Android
|
||||||
|
Reference in New Issue
Block a user