forked from qt-creator/qt-creator
Android: Handle some Qt deprecation related warnings
... in manifest editor. Change-Id: I7e33f6e96ef88c8a5fb3f5d509bccab9ceebe799 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -488,21 +488,40 @@ void AndroidManifestEditorWidget::focusInEvent(QFocusEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
static bool checkDocument(const QDomDocument &doc, QDomDocument::ParseResult *result)
|
||||
{
|
||||
QDomElement manifest = doc.documentElement();
|
||||
if (manifest.tagName() != QLatin1String("manifest")) {
|
||||
result->errorMessage = ::Android::Tr::tr("The structure of the Android manifest file "
|
||||
"is corrupted. Expected a top level 'manifest' node.");
|
||||
result->errorLine = -1;
|
||||
result->errorColumn = -1;
|
||||
return false;
|
||||
}
|
||||
if (manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")).isNull()) {
|
||||
// missing either application or activity element
|
||||
result->errorMessage = ::Android::Tr::tr("The structure of the Android manifest file "
|
||||
"is corrupted. Expected an 'application' and 'activity' sub node.");
|
||||
result->errorLine = -1;
|
||||
result->errorColumn = -1;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::updateAfterFileLoad()
|
||||
{
|
||||
QString error;
|
||||
int errorLine;
|
||||
int errorColumn;
|
||||
QDomDocument doc;
|
||||
if (doc.setContent(m_textEditorWidget->toPlainText(), &error, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &error, &errorLine, &errorColumn)) {
|
||||
QDomDocument::ParseResult result = doc.setContent(m_textEditorWidget->toPlainText());
|
||||
if (result) {
|
||||
if (checkDocument(doc, &result)) {
|
||||
if (activePage() != Source)
|
||||
syncToWidgets(doc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// some error occurred
|
||||
updateInfoBar(error, errorLine, errorColumn);
|
||||
updateInfoBar(result.errorMessage, result.errorLine, result.errorColumn);
|
||||
setActivePage(Source);
|
||||
}
|
||||
|
||||
@@ -591,39 +610,19 @@ TextEditor::TextEditorWidget *AndroidManifestEditorWidget::textEditorWidget() co
|
||||
bool AndroidManifestEditorWidget::syncToWidgets()
|
||||
{
|
||||
QDomDocument doc;
|
||||
QString errorMessage;
|
||||
int errorLine, errorColumn;
|
||||
if (doc.setContent(m_textEditorWidget->toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||
QDomDocument::ParseResult result = doc.setContent(m_textEditorWidget->toPlainText());
|
||||
if (result) {
|
||||
if (checkDocument(doc, &result)) {
|
||||
hideInfoBar();
|
||||
syncToWidgets(doc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
updateInfoBar(errorMessage, errorLine, errorColumn);
|
||||
updateInfoBar(result.errorMessage, result.errorLine, result.errorColumn);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AndroidManifestEditorWidget::checkDocument(const QDomDocument &doc, QString *errorMessage,
|
||||
int *errorLine, int *errorColumn)
|
||||
{
|
||||
QDomElement manifest = doc.documentElement();
|
||||
if (manifest.tagName() != QLatin1String("manifest")) {
|
||||
*errorMessage = ::Android::Tr::tr("The structure of the Android manifest file is corrupted. Expected a top level 'manifest' node.");
|
||||
*errorLine = -1;
|
||||
*errorColumn = -1;
|
||||
return false;
|
||||
} else if (manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")).isNull()) {
|
||||
// missing either application or activity element
|
||||
*errorMessage = ::Android::Tr::tr("The structure of the Android manifest file is corrupted. Expected an 'application' and 'activity' sub node.");
|
||||
*errorLine = -1;
|
||||
*errorColumn = -1;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::startParseCheck()
|
||||
{
|
||||
m_timerParseCheck.start();
|
||||
@@ -641,16 +640,15 @@ void AndroidManifestEditorWidget::updateInfoBar()
|
||||
return;
|
||||
}
|
||||
QDomDocument doc;
|
||||
int errorLine, errorColumn;
|
||||
QString errorMessage;
|
||||
if (doc.setContent(m_textEditorWidget->toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||
QDomDocument::ParseResult result = doc.setContent(m_textEditorWidget->toPlainText());
|
||||
if (result) {
|
||||
if (checkDocument(doc, &result)) {
|
||||
hideInfoBar();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
updateInfoBar(errorMessage, errorLine, errorColumn);
|
||||
updateInfoBar(result.errorMessage, result.errorLine, result.errorColumn);
|
||||
}
|
||||
|
||||
void AndroidManifestEditorWidget::updateSdkVersions()
|
||||
@@ -888,9 +886,9 @@ void AndroidManifestEditorWidget::syncToEditor()
|
||||
m_dirty = false;
|
||||
}
|
||||
|
||||
namespace {
|
||||
QXmlStreamAttributes modifyXmlStreamAttributes(const QXmlStreamAttributes &input, const QStringList &keys,
|
||||
const QStringList &values, const QStringList &remove = QStringList())
|
||||
static QXmlStreamAttributes modifyXmlStreamAttributes(
|
||||
const QXmlStreamAttributes &input, const QStringList &keys,
|
||||
const QStringList &values, const QStringList &remove = {})
|
||||
{
|
||||
Q_ASSERT(keys.size() == values.size());
|
||||
QXmlStreamAttributes result;
|
||||
@@ -903,8 +901,7 @@ QXmlStreamAttributes modifyXmlStreamAttributes(const QXmlStreamAttributes &input
|
||||
if (index == -1)
|
||||
result.push_back(attribute);
|
||||
else
|
||||
result.push_back(QXmlStreamAttribute(name,
|
||||
values.at(index)));
|
||||
result.push_back(QXmlStreamAttribute(name, values.at(index)));
|
||||
}
|
||||
|
||||
for (int i = 0; i < keys.size(); ++i) {
|
||||
@@ -913,7 +910,6 @@ QXmlStreamAttributes modifyXmlStreamAttributes(const QXmlStreamAttributes &input
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // end namespace
|
||||
|
||||
void AndroidManifestEditorWidget::parseManifest(QXmlStreamReader &reader, QXmlStreamWriter &writer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user