forked from qt-creator/qt-creator
Revert "Android: Handle some Qt deprecation related warnings"
This reverts commit a69ee57396.
Too early: QDomDocument::ParseResult was only introduced in Qt 6.5.
Change-Id: Ia2590a3f8ce5b9edec21b222d5c9211572563f97
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -488,40 +488,21 @@ 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()
|
void AndroidManifestEditorWidget::updateAfterFileLoad()
|
||||||
{
|
{
|
||||||
|
QString error;
|
||||||
|
int errorLine;
|
||||||
|
int errorColumn;
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomDocument::ParseResult result = doc.setContent(m_textEditorWidget->toPlainText());
|
if (doc.setContent(m_textEditorWidget->toPlainText(), &error, &errorLine, &errorColumn)) {
|
||||||
if (result) {
|
if (checkDocument(doc, &error, &errorLine, &errorColumn)) {
|
||||||
if (checkDocument(doc, &result)) {
|
|
||||||
if (activePage() != Source)
|
if (activePage() != Source)
|
||||||
syncToWidgets(doc);
|
syncToWidgets(doc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// some error occurred
|
// some error occurred
|
||||||
updateInfoBar(result.errorMessage, result.errorLine, result.errorColumn);
|
updateInfoBar(error, errorLine, errorColumn);
|
||||||
setActivePage(Source);
|
setActivePage(Source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,19 +591,39 @@ TextEditor::TextEditorWidget *AndroidManifestEditorWidget::textEditorWidget() co
|
|||||||
bool AndroidManifestEditorWidget::syncToWidgets()
|
bool AndroidManifestEditorWidget::syncToWidgets()
|
||||||
{
|
{
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomDocument::ParseResult result = doc.setContent(m_textEditorWidget->toPlainText());
|
QString errorMessage;
|
||||||
if (result) {
|
int errorLine, errorColumn;
|
||||||
if (checkDocument(doc, &result)) {
|
if (doc.setContent(m_textEditorWidget->toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||||
|
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||||
hideInfoBar();
|
hideInfoBar();
|
||||||
syncToWidgets(doc);
|
syncToWidgets(doc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateInfoBar(result.errorMessage, result.errorLine, result.errorColumn);
|
updateInfoBar(errorMessage, errorLine, errorColumn);
|
||||||
return false;
|
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()
|
void AndroidManifestEditorWidget::startParseCheck()
|
||||||
{
|
{
|
||||||
m_timerParseCheck.start();
|
m_timerParseCheck.start();
|
||||||
@@ -640,15 +641,16 @@ void AndroidManifestEditorWidget::updateInfoBar()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomDocument::ParseResult result = doc.setContent(m_textEditorWidget->toPlainText());
|
int errorLine, errorColumn;
|
||||||
if (result) {
|
QString errorMessage;
|
||||||
if (checkDocument(doc, &result)) {
|
if (doc.setContent(m_textEditorWidget->toPlainText(), &errorMessage, &errorLine, &errorColumn)) {
|
||||||
|
if (checkDocument(doc, &errorMessage, &errorLine, &errorColumn)) {
|
||||||
hideInfoBar();
|
hideInfoBar();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateInfoBar(result.errorMessage, result.errorLine, result.errorColumn);
|
updateInfoBar(errorMessage, errorLine, errorColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::updateSdkVersions()
|
void AndroidManifestEditorWidget::updateSdkVersions()
|
||||||
@@ -886,9 +888,9 @@ void AndroidManifestEditorWidget::syncToEditor()
|
|||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QXmlStreamAttributes modifyXmlStreamAttributes(
|
namespace {
|
||||||
const QXmlStreamAttributes &input, const QStringList &keys,
|
QXmlStreamAttributes modifyXmlStreamAttributes(const QXmlStreamAttributes &input, const QStringList &keys,
|
||||||
const QStringList &values, const QStringList &remove = {})
|
const QStringList &values, const QStringList &remove = QStringList())
|
||||||
{
|
{
|
||||||
Q_ASSERT(keys.size() == values.size());
|
Q_ASSERT(keys.size() == values.size());
|
||||||
QXmlStreamAttributes result;
|
QXmlStreamAttributes result;
|
||||||
@@ -901,7 +903,8 @@ static QXmlStreamAttributes modifyXmlStreamAttributes(
|
|||||||
if (index == -1)
|
if (index == -1)
|
||||||
result.push_back(attribute);
|
result.push_back(attribute);
|
||||||
else
|
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) {
|
for (int i = 0; i < keys.size(); ++i) {
|
||||||
@@ -910,6 +913,7 @@ static QXmlStreamAttributes modifyXmlStreamAttributes(
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
} // end namespace
|
||||||
|
|
||||||
void AndroidManifestEditorWidget::parseManifest(QXmlStreamReader &reader, QXmlStreamWriter &writer)
|
void AndroidManifestEditorWidget::parseManifest(QXmlStreamReader &reader, QXmlStreamWriter &writer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,11 +14,14 @@
|
|||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QDomDocument;
|
class QDomDocument;
|
||||||
|
class QDomElement;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QListView;
|
class QListView;
|
||||||
|
class QSpinBox;
|
||||||
|
class QToolButton;
|
||||||
class QXmlStreamReader;
|
class QXmlStreamReader;
|
||||||
class QXmlStreamWriter;
|
class QXmlStreamWriter;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -105,6 +108,9 @@ private:
|
|||||||
void syncToEditor();
|
void syncToEditor();
|
||||||
void updateAfterFileLoad();
|
void updateAfterFileLoad();
|
||||||
|
|
||||||
|
bool checkDocument(const QDomDocument &doc, QString *errorMessage,
|
||||||
|
int *errorLine, int *errorColumn);
|
||||||
|
|
||||||
void updateInfoBar(const QString &errorMessage, int line, int column);
|
void updateInfoBar(const QString &errorMessage, int line, int column);
|
||||||
void hideInfoBar();
|
void hideInfoBar();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user