Commit dd32d1a1 authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Thomas Hartmann

QmlDesigner: Add error channel from puppet -> designer

Change-Id: I57c325fd98ed505abc19f87ac8a164d7e0c76244
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 6d817307
......@@ -173,6 +173,7 @@ public:
void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void emitInstancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList);
void emitInstanceErrorChange(const QVector<qint32> &instanceIds);
void emitInstancesCompleted(const QVector<ModelNode> &nodeList);
void emitInstanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash);
void emitInstancesRenderImageChanged(const QVector<ModelNode> &nodeList);
......@@ -214,6 +215,7 @@ public:
virtual void rewriterEndTransaction() = 0;
virtual void currentStateChanged(const ModelNode &node) = 0; // base state is a invalid model node
virtual void instanceErrorChange(const QVector<ModelNode> &errorNodeList);
virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList) = 0;
......
......@@ -94,6 +94,8 @@ public:
void setY(double y);
bool hasAnchors() const;
QString error() const;
bool hasError() const;
protected:
void setProperty(const PropertyName &name, const QVariant &value);
......@@ -124,6 +126,7 @@ protected:
void setParentId(qint32 instanceId);
void setRenderPixmap(const QImage &image);
bool setError(const QString &errorMessage);
NodeInstance(ProxyNodeInstanceData *d);
private:
......
......@@ -55,6 +55,8 @@ public:
static bool isValidQmlObjectNode(const ModelNode &modelNode);
bool isValid() const;
bool hasError() const;
QString error() const;
bool hasNodeParent() const;
bool hasInstanceParent() const;
bool hasInstanceParentItem() const;
......
......@@ -84,6 +84,8 @@ public:
QPixmap renderPixmap;
QPixmap blurredRenderPixmap;
QString errorMessage;
QHash<PropertyName, QPair<PropertyName, qint32> > anchors;
};
......@@ -179,6 +181,17 @@ bool NodeInstance::hasAnchors() const
|| hasAnchor("anchors.baseline");
}
QString NodeInstance::error() const
{
return d->errorMessage;
}
bool NodeInstance::hasError() const
{
return !d->errorMessage.isEmpty();
}
bool NodeInstance::isValid() const
{
return instanceId() >= 0 && modelNode().isValid();
......@@ -392,6 +405,15 @@ void NodeInstance::setRenderPixmap(const QImage &image)
d->blurredRenderPixmap = QPixmap();
}
bool NodeInstance::setError(const QString &errorMessage)
{
if (d->errorMessage != errorMessage) {
d->errorMessage = errorMessage;
return true;
}
return false;
}
void NodeInstance::setParentId(qint32 instanceId)
{
d->parentInstanceId = instanceId;
......
......@@ -192,6 +192,11 @@ void AbstractView::modelAboutToBeDetached(Model *)
Empty properties were removed.
*/
void AbstractView::instanceErrorChange(const QVector<ModelNode> &/*errorNodeList*/)
{
}
// Node related functions
/*!
......@@ -462,6 +467,12 @@ void AbstractView::emitInstancePropertyChange(const QList<QPair<ModelNode, Prope
model()->d->notifyInstancePropertyChange(propertyList);
}
void AbstractView::emitInstanceErrorChange(const QVector<qint32> &instanceIds)
{
if (model() && nodeInstanceView() == this)
model()->d->notifyInstanceErrorChange(instanceIds);
}
void AbstractView::emitInstancesCompleted(const QVector<ModelNode> &nodeVector)
{
if (model() && nodeInstanceView() == this)
......
......@@ -435,6 +435,19 @@ void ModelPrivate::notifyInstancePropertyChange(const QList<QPair<ModelNode, Pro
}
}
void ModelPrivate::notifyInstanceErrorChange(const QVector<qint32> &instanceIds)
{
// no need to notify the rewriter or the instance view
QVector<ModelNode> errorNodeList;
foreach (const QPointer<AbstractView> &view, m_viewList) {
Q_ASSERT(view != 0);
foreach (qint32 instanceId, instanceIds)
errorNodeList.append(ModelNode(model()->d->nodeForInternalId(instanceId), model(), view));
view->instanceErrorChange(errorNodeList);
}
}
void ModelPrivate::notifyInstancesCompleted(const QVector<ModelNode> &nodeVector)
{
bool resetModel = false;
......
......@@ -152,6 +152,7 @@ public:
void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void notifyInstancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList);
void notifyInstanceErrorChange(const QVector<qint32> &instanceIds);
void notifyInstancesCompleted(const QVector<ModelNode> &nodeList);
void notifyInstancesInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash);
void notifyInstancesRenderImageChanged(const QVector<ModelNode> &nodeList);
......
......@@ -486,6 +486,22 @@ bool QmlObjectNode::isValid() const
return isValidQmlObjectNode(modelNode());
}
bool QmlObjectNode::hasError() const
{
if (isValid())
return nodeInstance().hasError();
else
qDebug() << "called hasError() on an invalid QmlObjectNode";
return false;
}
QString QmlObjectNode::error() const
{
if (hasError())
return nodeInstance().error();
return QString();
}
bool QmlObjectNode::hasNodeParent() const
{
return modelNode().hasParentProperty();
......
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