Commit 8771ced0 authored by Tobias Nätterlund's avatar Tobias Nätterlund Committed by Eike Ziller
Browse files

QNX: Fixed changed XML content not being saved



The problem occurred when changing the XML source code
in the source editor, and not switching to any of the
widget views before saving.

Change-Id: I6831f54d8cb4b94dbc02aa3c305c2e9839f1c64c
Reviewed-by: default avatarMehdi Fekari <mfekari@rim.com>
Reviewed-by: Nicolas Arnaud-Cormos's avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 9b22c8ed
......@@ -32,6 +32,7 @@
#include "bardescriptordocument.h"
#include "qnxconstants.h"
#include "bardescriptoreditor.h"
#include "bardescriptoreditorwidget.h"
#include "bardescriptordocumentnodehandlers.h"
......@@ -185,24 +186,31 @@ void BarDescriptorDocument::rename(const QString &newName)
QString BarDescriptorDocument::xmlSource() const
{
QDomDocument doc;
doc.appendChild(doc.createProcessingInstruction(QLatin1String("xml"), QLatin1String("version='1.0' encoding='") + QLatin1String(codec()->name()) + QLatin1String("' standalone='no'")));
BarDescriptorEditor *editor = qobject_cast<BarDescriptorEditor*>(m_editorWidget->editor());
QTC_ASSERT(editor, return QString());
// QNX
QDomElement rootElem = doc.createElement(QLatin1String("qnx"));
rootElem.setAttribute(QLatin1String("xmlns"), QLatin1String("http://www.qnx.com/schemas/application/1.0"));
if (editor->activePage() == BarDescriptorEditor::Source) {
return m_editorWidget->xmlSource();
} else {
QDomDocument doc;
doc.appendChild(doc.createProcessingInstruction(QLatin1String("xml"), QLatin1String("version='1.0' encoding='") + QLatin1String(codec()->name()) + QLatin1String("' standalone='no'")));
QMap<int, BarDescriptorDocumentAbstractNodeHandler*> nodeHandlerMap;
foreach (BarDescriptorDocumentAbstractNodeHandler *nodeHandler, m_nodeHandlers)
nodeHandlerMap.insertMulti(nodeHandler->order(), nodeHandler);
// QNX
QDomElement rootElem = doc.createElement(QLatin1String("qnx"));
rootElem.setAttribute(QLatin1String("xmlns"), QLatin1String("http://www.qnx.com/schemas/application/1.0"));
QList<BarDescriptorDocumentAbstractNodeHandler*> nodeHandlers = nodeHandlerMap.values();
foreach (BarDescriptorDocumentAbstractNodeHandler *nodeHandler, nodeHandlers)
rootElem.appendChild(nodeHandler->toNode(doc));
QMap<int, BarDescriptorDocumentAbstractNodeHandler*> nodeHandlerMap;
foreach (BarDescriptorDocumentAbstractNodeHandler *nodeHandler, m_nodeHandlers)
nodeHandlerMap.insertMulti(nodeHandler->order(), nodeHandler);
doc.appendChild(rootElem);
QList<BarDescriptorDocumentAbstractNodeHandler*> nodeHandlers = nodeHandlerMap.values();
foreach (BarDescriptorDocumentAbstractNodeHandler *nodeHandler, nodeHandlers)
rootElem.appendChild(nodeHandler->toNode(doc));
return doc.toString(4);
doc.appendChild(rootElem);
return doc.toString(4);
}
}
bool BarDescriptorDocument::loadContent(const QString &xmlSource, QString *errorMessage, int *errorLine)
......
......@@ -151,6 +151,14 @@ QWidget *BarDescriptorEditor::toolBar()
return m_toolBar;
}
BarDescriptorEditor::EditorPage BarDescriptorEditor::activePage() const
{
BarDescriptorEditorWidget *editorWidget = qobject_cast<BarDescriptorEditorWidget *>(widget());
QTC_ASSERT(editorWidget, return static_cast<EditorPage>(-1));
return static_cast<EditorPage>(editorWidget->currentIndex());
}
void BarDescriptorEditor::changeEditorPage(QAction *action)
{
setActivePage(static_cast<EditorPage>(action->data().toInt()));
......
......@@ -54,6 +54,13 @@ class BarDescriptorEditor : public Core::IEditor
{
Q_OBJECT
public:
enum EditorPage {
General = 0,
Application,
Assets,
Source
};
explicit BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget);
bool createNew(const QString &contents = QString());
......@@ -73,17 +80,12 @@ public:
QWidget *toolBar();
EditorPage activePage() const;
private slots:
void changeEditorPage(QAction *action);
private:
enum EditorPage {
General = 0,
Application,
Assets,
Source
};
ProjectExplorer::TaskHub *taskHub();
void setActivePage(EditorPage page);
......
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