Commit f660096e authored by Denis Gofman's avatar Denis Gofman
Browse files

Merge branch 'alex_issue-139' into 'master'

Z-level of nesteds and Undo/Redo bananas

See merge request esa/taste3!180
parents 4fb4ce11 3a63bc63
Pipeline #1539 failed with stage
......@@ -233,6 +233,7 @@ QHash<QString, QVariantList> XmlDocExporter::collectInterfaceObjects(document::I
case aadl::AADLObject::AADLObjectType::AADLFunctionType:
case aadl::AADLObject::AADLObjectType::AADLFunction:
case aadl::AADLObject::AADLObjectType::AADLComment:
case aadl::AADLObject::AADLObjectType::AADLConnection:
case aadl::AADLObject::AADLObjectType::AADLUnknown: {
if (t == aadl::AADLObject::AADLObjectType::AADLUnknown || aadlObject->isNested())
continue;
......
......@@ -188,6 +188,16 @@ QVariantList AADLObjectFunctionType::templateComments() const
return comments;
}
QVariantList AADLObjectFunctionType::templateConnections() const
{
QVariantList connections;
for (const auto child : d->m_children) {
if (child->aadlType() == AADLObject::AADLObjectType::AADLConnection)
connections << QVariant::fromValue(child);
}
return connections;
}
QVector<ContextParameter> AADLObjectFunctionType::contextParams() const
{
return d->m_contextParams;
......
......@@ -36,6 +36,7 @@ class AADLObjectFunctionType : public AADLObject
Q_PROPERTY(QVariantList interfaces READ templateInterfaces) //!< Iinterface list for string templates
Q_PROPERTY(QVariantList functions READ templateFunctions) //!< Function list for string templates
Q_PROPERTY(QVariantList comments READ templateComments) //!< Comment list for string templates
Q_PROPERTY(QVariantList connections READ templateConnections) //!< Connection list for string templates
public:
explicit AADLObjectFunctionType(const QString &title = QString(), QObject *parent = nullptr);
~AADLObjectFunctionType() override;
......@@ -61,6 +62,7 @@ public:
QVariantList templateInterfaces() const;
QVariantList templateFunctions() const;
QVariantList templateComments() const;
QVariantList templateConnections() const;
QVector<ContextParameter> contextParams() const;
ContextParameter contextParam(const QString &name) const;
......
......@@ -288,7 +288,7 @@ void AADLXMLReader::processTagOpen(QXmlStreamReader &xml)
break;
}
case Props::Token::Connection: {
obj = new AADLObjectConnection(nullptr, nullptr, nullptr, nullptr, d->m_currentObject.get());
obj = addConnection();
break;
}
case Props::Token::Source:
......@@ -384,5 +384,15 @@ AADLObjectComment *AADLXMLReader::addComment(const QString &text)
return comment;
}
AADLObjectConnection *AADLXMLReader::addConnection()
{
AADLObjectConnection *connection =
new AADLObjectConnection(nullptr, nullptr, nullptr, nullptr, d->m_currentObject.get());
if (d->m_currentObject.function())
d->m_currentObject.function()->addChild(connection);
return connection;
}
} // ns aadl
} // ns taste3
......@@ -32,6 +32,7 @@ namespace aadl {
class AADLObjectIface;
class AADLObjectFunctionType;
class AADLObjectComment;
class AADLObjectConnection;
struct AADLXMLReaderPrivate;
class AADLXMLReader : public QObject
{
......@@ -60,6 +61,7 @@ private:
AADLObjectFunctionType *addFunction(const QString &name, AADLObject::AADLObjectType fnType);
AADLObjectIface *addIface(const QString &name, bool isRI);
AADLObjectComment *addComment(const QString &text);
AADLObjectConnection *addConnection();
};
} // ns aadl
......
......@@ -34,6 +34,7 @@ CmdConnectionItemCreate::CmdConnectionItemCreate(AADLObjectsModel *model, AADLOb
const QVector<QPointF> &points)
: CmdEntityGeometryChange({}, QObject::tr("Create Connection"))
, m_model(model)
, m_parent(parent)
{
Q_ASSERT(model);
Q_ASSERT(!sourceIfaceId.isNull());
......@@ -43,7 +44,6 @@ CmdConnectionItemCreate::CmdConnectionItemCreate(AADLObjectsModel *model, AADLOb
AADLObjectIface *targetIface = m_model->getInterface(targetIfaceId);
m_entity = new AADLObjectConnection(sourceIface->function(), targetIface->function(), sourceIface, targetIface,
parent);
prepareData({ qMakePair(m_entity, points) });
}
......@@ -51,6 +51,8 @@ void CmdConnectionItemCreate::redo()
{
CmdEntityGeometryChange::redo();
if (m_parent)
m_parent->addChild(m_entity);
m_model->addObject(m_entity);
m_entity->inheritLabel();
}
......@@ -61,6 +63,8 @@ void CmdConnectionItemCreate::undo()
m_entity->uninheritLabel();
m_model->removeObject(m_entity);
if (m_parent)
m_parent->removeChild(m_entity);
}
int CmdConnectionItemCreate::id() const
......
......@@ -26,7 +26,6 @@
namespace taste3 {
namespace aadl {
class AADLObjectIface;
class AADLObjectConnection;
class AADLObjectFunction;
class AADLObjectsModel;
......@@ -46,6 +45,7 @@ public:
private:
QPointer<AADLObjectsModel> m_model;
QPointer<AADLObjectConnection> m_entity;
QPointer<AADLObjectFunction> m_parent;
};
} // namespace cmd
......
......@@ -216,8 +216,6 @@ bool InterfaceTabDocument::createImpl(const QString &path)
if (!path.isEmpty())
return loadImpl(path);
const QRect r(0, 0, 1000, 1000);
m_graphicsScene->setSceneRect(m_graphicsView->mapToScene(r).boundingRect());
return true;
}
......
......@@ -16,6 +16,8 @@ func.functions : |_ List of all nested functions of function
func : |_ Instance of nested function
func.comments : |_ List of all nested comments of function
comm : |_ Instance of nested comment
func.connections: |_ List of all nested connections of function
conn : |_ Instance of nested connections
{% endcomment %}
<Function{% for attr in func.attributes %} {{ attr.name }}="{{ attr.value }}"{% endfor %}>
{% for prop in func.properties %}
......@@ -30,4 +32,7 @@ comm : |_ Instance of nested comment
{% for comm in func.comments %}
{% include "comment.tmplt" %}
{% endfor %}
{% for conn in func.connections %}
{% include "connection.tmplt" %}
{% endfor %}
</Function>
......@@ -3,7 +3,7 @@ Template for generation of XML scheme of the whole interface view.
The following tags are available in this template:
Functions : List of all available NON-nested functions (provided by application)
func : |_ Instance of function
Connections : List of all available connections (provided by application)
Connections : List of all available NON-nested connections (provided by application). Connections between top-level functions;
conn : |_ Instance of connection
Comments : List of all available NON-nested comments (provided by application)
comm : |_ Instance of comment
......
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