diff --git a/KactusAPI/KactusAPI.vcxproj.filters b/KactusAPI/KactusAPI.vcxproj.filters
index b70d2b06e..f37668bf2 100644
--- a/KactusAPI/KactusAPI.vcxproj.filters
+++ b/KactusAPI/KactusAPI.vcxproj.filters
@@ -292,10 +292,10 @@
Header Files\include
- Generated Files
+ Header Files\include
- Generated Files
+ Header Files\include
@@ -510,7 +510,7 @@
Source Files\interfaces\component
- Generated Files
+ Source Files\utilities
diff --git a/KactusAPI/include/DocumentValidator.h b/KactusAPI/include/DocumentValidator.h
index df87ad568..247ae0b7e 100644
--- a/KactusAPI/include/DocumentValidator.h
+++ b/KactusAPI/include/DocumentValidator.h
@@ -118,6 +118,9 @@ class DocumentValidator
//! The parameter finder used in the component validator.
QSharedPointer componentValidatorFinder_{ new ParameterCache(QSharedPointer()) };
+ //! The parameter finder used in the abstraction definition validator.
+ QSharedPointer absDefParameterFinder_{ new ListParameterFinder() };
+
//! The used abstraction definition validator.
AbstractionDefinitionValidator abstractionValidator_;
diff --git a/KactusAPI/include/PortAbstractionInterface.h b/KactusAPI/include/PortAbstractionInterface.h
index 2d1e658b3..bafbad8cd 100644
--- a/KactusAPI/include/PortAbstractionInterface.h
+++ b/KactusAPI/include/PortAbstractionInterface.h
@@ -13,6 +13,7 @@
#define PORTABSTRACTIONINTERFACE_H
#include
+#include
#include "KactusAPI/KactusAPIGlobal.h"
@@ -29,18 +30,25 @@ class TransactionalPort;
class WirePort;
class Protocol;
class AbstractionDefinition;
+class PortAbstractionValidator;
+class ExpressionParser;
+class ExpressionFormatter;
//-----------------------------------------------------------------------------
//! Interface for editing abstraction definition port abstractions.
//-----------------------------------------------------------------------------
-class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
+class KACTUS2_API PortAbstractionInterface : public MasterPortInterface, public ParameterizableInterface
{
public:
/*!
- * The constructor.
+ * The constructor.
+ *
+ * @param [in] expressionParser The expression parser to use.
+ * @param [in] expressionFormatter The expression formatter to use.
*/
- PortAbstractionInterface();
+ PortAbstractionInterface(QSharedPointer expressionParser,
+ QSharedPointer expressionFormatter);
/*!
* The destructor.
@@ -54,6 +62,13 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*/
void setAbsDef(QSharedPointer absDef);
+ /*!
+ * Set the validator to use.
+ *
+ * @param [in] validator The validator to use.
+ */
+ void setPortAbstractionValidator(QSharedPointer validator);
+
/*!
* Get index of the first signal containing the selected port abstraction.
*
@@ -119,14 +134,14 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @return True, if successful, false otherwise.
*/
- virtual bool setName(std::string const& currentName, std::string const& newName) override final;
+ bool setName(std::string const& currentName, std::string const& newName) final;
/*!
* Validates the contained port abstractions.
*
* @return True, if all the port abstractions are valid, false otherwise.
*/
- virtual bool validateItems() const override final;
+ bool validateItems() const final;
/*!
* Check if the selected port abstraction has a valid name.
@@ -135,7 +150,25 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @return True, if the name is valid, false otherwise.
*/
- virtual bool itemHasValidName(std::string const& itemName) const override final;
+ bool itemHasValidName(std::string const& itemName) const final;
+
+ /*!
+ * Check if the width of the wire port is valid.
+ *
+ * @param [in] portIndex The index of the selected signal.
+ *
+ * @return True, if the widht is valid, otherwise false.
+ */
+ bool wireHasValidWidth(int portIndex) const;
+
+ /*!
+ * Check if the default value of the wire port is valid.
+ *
+ * @param [in] portIndex The index of the selected signal.
+ *
+ * @return True, if the default value is valid, otherwise false.
+ */
+ bool wireHasValidDefaultValue(int portIndex) const;
/*!
* Get the match status of the selected signal.
@@ -161,7 +194,7 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @return Names of the available ports abstractions.
*/
- virtual std::vector getItemNames() const override final;
+ std::vector getItemNames() const final;
/*!
* Get the list of logical ports with the selected bus interface mode and system group.
@@ -343,16 +376,16 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
bool setDirection(int const& portIndex, std::string const& newDirection);
/*!
- * Get the width of the selected signal.
+ * Get the width expression of the selected signal.
*
* @param [in] portIndex Index of the selected signal.
*
* @return Width of the selected signal.
*/
- std::string getWidth(int const& portIndex) const;
+ std::string getWidthExpression(int const& portIndex) const;
/*!
- * Get the width of the selected signal.
+ * Get the width expression of the selected signal.
*
* @param [in] portName Name of the selected port.
* @param [in] interfaceMode The selected bus interface mode in string form.
@@ -360,11 +393,11 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @return Width of the selected signal.
*/
- std::string getWidth(std::string const& portName, std::string const& interfaceMode,
+ std::string getWidthExpression(std::string const& portName, std::string const& interfaceMode,
std::string const& systemGroup) const;
/*!
- * Get the width of the selected signal.
+ * Get the width expression of the selected signal.
*
* @param [in] portName Name of the selected port.
* @param [in] interfaceMode The selected bus interface mode.
@@ -372,9 +405,39 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @return Width of the selected signal.
*/
- std::string getWidth(std::string const& portName, General::InterfaceMode interfaceMode,
+ std::string getWidthExpression(std::string const& portName, General::InterfaceMode interfaceMode,
std::string const& systemGroup) const;
+ /*!
+ * Get the formatted expression for the width of the selected wire port.
+ *
+ * @param [in] portIndex Index of the selected signal.
+ *
+ * @return The formatted expression of the width.
+ */
+ std::string getWidthFormattedExpression(int portIndex) const;
+
+ /*!
+ * Get the width value of the selected signal.
+ *
+ * @param [in] portIndex Index of the selected signal.
+ * @param [in] baseNumber Base number to format the value to.
+ *
+ * @return The evaluated value of the wire width.
+ */
+ std::string getWidthValue(int portIndex, int baseNumber = 0) const;
+
+ /*!
+ * Get the width value of the selected signal.
+ *
+ * @param [in] portName Name of the selected port.
+ * @param [in] interfaceMode The interface mode of the port.
+ * @param [in] systemGroup The port system group.
+ *
+ * @return The evaluated value of the wire width.
+ */
+ std::string getWidthValue(std::string const& portName, General::InterfaceMode interfaceMode, std::string const& systemGroup) const;
+
/*!
* Set a new width for the selected signal.
*
@@ -438,14 +501,33 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
bool setPresence(int const& portIndex, std::string const& newPresence);
/*!
- * Get the default value of the selected signal.
+ * Get the default value expression of the selected signal.
*
* @param [in] portIndex Index of the selected signal.
*
* @return Default value of the selected signal.
*/
- std::string getDefaultValue(int const& portIndex) const;
+ std::string getDefaultValueExpression(int const& portIndex) const;
+ /*!
+ * Get the formatted expression default value of the selected signal.
+ *
+ * @param [in] portIndex Index of the selected signal.
+ *
+ * @return Default value of the selected signal.
+ */
+ std::string getDefaultValueFormattedExpression(int const& portIndex) const;
+
+ /*!
+ * Get the evaluated default value of the selected signal.
+ *
+ * @param [in] portIndex Index of the selected signal.
+ * @param [in] baseNumber The base to format the value to.
+ *
+ * @return Default value of the selected signal.
+ */
+ std::string getDefaultValueValue(int const& portIndex, int baseNumber = 0) const;
+
/*!
* Set a new default value for the selected signal.
*
@@ -476,16 +558,16 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
bool setDriverType(int const& portIndex, std::string const& newDriver);
/*!
- * Get the bus width of the selected signal.
+ * Get the bus width expression of the selected signal.
*
* @param [in] portIndex Index of the selected signal.
*
* @return Bus width of the selected signal.
*/
- std::string getBusWidthValue(int const& portIndex) const;
+ std::string getBusWidthExpression(int const& portIndex) const;
/*!
- * Get the bus width of the selected signal.
+ * Get the bus width expression of the selected signal.
*
* @param [in] portName Name of the selected port.
* @param [in] interfaceMode The selected bus interface mode.
@@ -493,9 +575,28 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @return Bus width of the selected signal.
*/
- std::string getBusWidthValue(std::string const& portName, std::string const& interfaceMode,
+ std::string getBusWidthExpression(std::string const& portName, std::string const& interfaceMode,
std::string const& systemGroup) const;
+ /*!
+ * Get the formatted expression of the bus width of the selected signal.
+ *
+ * @param [in] portIndex Index of the selected signal.
+ *
+ * @return Bus width of the selected signal.
+ */
+ std::string getBusWidthFormattedExpression(int signalIndex) const;
+
+ /*!
+ * Get the evaluated value of the bus width of the selected signal.
+ *
+ * @param [in] portIndex Index of the selected signal.
+ * @param [in] baseNumber The base to format the value to.
+ *
+ * @return Bus width of the selected signal.
+ */
+ std::string getBusWidthValue(int portIndex, int baseNumber = 0) const;
+
/*!
* Set a new bus width for the selected signal.
*
@@ -506,6 +607,8 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*/
bool setBusWidth(int const& portIndex, std::string const& newBusWidth);
+ bool transactionalHasValidBusWidth(int portIndex) const;
+
/*!
* Get the initiative of the selected signal.
*
@@ -646,14 +749,14 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @param [in] newPortName Name of the new port.
*/
- virtual void addWirePort(std::string const& newPortName = std::string("")) override final;
+ void addWirePort(std::string const& newPortName = std::string("")) final;
/*!
* Add a port abstraction containing transactional.
*
* @param [in] newPortName Name of the new port.
*/
- virtual void addTransactionalPort(std::string const& newPortName = std::string("")) override final;
+ void addTransactionalPort(std::string const& newPortName = std::string("")) final;
/*!
* Add a wire signal with the selected interface mode to the selected port abstraction.
@@ -703,7 +806,7 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @return True, if the selected port abstraction contains a wire, false otherwise.
*/
- virtual bool portIsWire(std::string const& portName) const override final;
+ bool portIsWire(std::string const& portName) const final;
/*!
* Check if the selected port abstraction contains a transactional.
@@ -712,7 +815,7 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*
* @return True, if the selected port abstraction contains a transactional, false otherwise.
*/
- virtual bool portIsTransactional(std::string const& portName) const override final;
+ bool portIsTransactional(std::string const& portName) const final;
/*!
* Get the icon path of the selected signal.
@@ -769,6 +872,17 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*/
Document::Revision getRevision() const;
+
+ /*!
+ * Get the number of references made to itemID on a given signal row.
+ *
+ * @param [in] signalIndex The index of the signal row.
+ * @param [in] itemID The parameter itemID to look for.
+ *
+ * @return Return the number of references made to itemID.
+ */
+ int getAllReferencesToIdInRow(int signalIndex, std::string const& itemID) const;
+
//! No copying. No assignment.
PortAbstractionInterface(const PortAbstractionInterface& other) = delete;
PortAbstractionInterface& operator=(const PortAbstractionInterface& other) = delete;
@@ -954,6 +1068,17 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
*/
Qualifier::Attribute getQualifierAttributeType(std::string const& attributeName) const;
+ /*!
+ * Calculate all the references to the selected ID in the selected item. Does nothing useful in this interface.
+ * Replaced by getAllReferencesToIdInRow().
+ *
+ * @param [in] itemName Name of the selected item.
+ * @param [in] valueID The selected ID.
+ *
+ * @return Number of references to the selected ID in the selected item.
+ */
+ int getAllReferencesToIdInItem(const std::string& itemName, std::string const& valueID) const final;
+
//-----------------------------------------------------------------------------
// Data.
//-----------------------------------------------------------------------------
@@ -966,6 +1091,9 @@ class KACTUS2_API PortAbstractionInterface : public MasterPortInterface
//! The standard revision of the abstraction definition.
Document::Revision abstractionStandardRevision_ = Document::Revision::Unknown;
+
+ //! The port valudator to use.
+ QSharedPointer portValidator_ = nullptr;
};
#endif // PORTABSTRACTIONINTERFACE_H
diff --git a/KactusAPI/interfaces/bus/PortAbstractionInterface.cpp b/KactusAPI/interfaces/bus/PortAbstractionInterface.cpp
index 9d52ce6e7..3d1941292 100644
--- a/KactusAPI/interfaces/bus/PortAbstractionInterface.cpp
+++ b/KactusAPI/interfaces/bus/PortAbstractionInterface.cpp
@@ -17,6 +17,7 @@
#include
#include
#include
+#include
#include
@@ -28,8 +29,10 @@ namespace
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::PortAbstractionInterface()
//-----------------------------------------------------------------------------
-PortAbstractionInterface::PortAbstractionInterface() :
+PortAbstractionInterface::PortAbstractionInterface(QSharedPointer expressionParser,
+ QSharedPointer expressionFormatter) :
MasterPortInterface(),
+ParameterizableInterface(expressionParser, expressionFormatter),
ports_(0),
signals_()
{
@@ -117,6 +120,14 @@ void PortAbstractionInterface::setAbsDef(QSharedPointer validator)
+{
+ portValidator_ = validator;
+}
+
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::createWireSignal()
//-----------------------------------------------------------------------------
@@ -172,6 +183,28 @@ Document::Revision PortAbstractionInterface::getRevision() const
return abstractionStandardRevision_;
}
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getAllReferencesToIdInRow()
+//-----------------------------------------------------------------------------
+int PortAbstractionInterface::getAllReferencesToIdInRow(int signalIndex, std::string const& itemID) const
+{
+ int referenceCount = 0;
+ if (auto signal = getSignal(signalIndex))
+ {
+ if (signal->wire_)
+ {
+ referenceCount += signal->wire_->getWidth().count(QString::fromStdString(itemID));
+ referenceCount += signal->abstraction_->getDefaultValue().count(QString::fromStdString(itemID));
+ }
+ else if (signal->transactional_)
+ {
+ referenceCount += signal->transactional_->getBusWidth().count(QString::fromStdString(itemID));
+ }
+ }
+
+ return referenceCount;
+}
+
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::getItem()
//-----------------------------------------------------------------------------
@@ -442,7 +475,38 @@ bool PortAbstractionInterface::validateItems() const
//-----------------------------------------------------------------------------
bool PortAbstractionInterface::itemHasValidName(std::string const& itemName) const
{
- return !itemName.empty();
+ if (auto port = getPort(itemName); portValidator_ && port)
+ {
+ return portValidator_->hasValidName(port);
+ }
+
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::wireHasValidWidth()
+//-----------------------------------------------------------------------------
+bool PortAbstractionInterface::wireHasValidWidth(int portIndex) const
+{
+ if (auto signal = getSignal(portIndex); portValidator_ && signal)
+ {
+ return portValidator_->wireHasValidWidth(signal->wire_);
+ }
+
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::wireHasValidDefaultValue()
+//-----------------------------------------------------------------------------
+bool PortAbstractionInterface::wireHasValidDefaultValue(int portIndex) const
+{
+ if (auto signal = getSignal(portIndex); portValidator_ && signal)
+ {
+ return portValidator_->wireHasValidDefaultValue(signal->abstraction_->getWire());
+ }
+
+ return false;
}
//-----------------------------------------------------------------------------
@@ -875,7 +939,7 @@ bool PortAbstractionInterface::setDirection(int const& portIndex, std::string co
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::getWidth()
//-----------------------------------------------------------------------------
-std::string PortAbstractionInterface::getWidth(int const& portIndex) const
+std::string PortAbstractionInterface::getWidthExpression(int const& portIndex) const
{
QSharedPointer selectedSignal = getSignal(portIndex);
if (selectedSignal && selectedSignal->wire_)
@@ -889,7 +953,7 @@ std::string PortAbstractionInterface::getWidth(int const& portIndex) const
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::getWidth()
//-----------------------------------------------------------------------------
-std::string PortAbstractionInterface::getWidth(std::string const& portName, std::string const& interfaceMode,
+std::string PortAbstractionInterface::getWidthExpression(std::string const& portName, std::string const& interfaceMode,
std::string const& systemGroup) const
{
QString signalWidth("");
@@ -908,7 +972,7 @@ std::string PortAbstractionInterface::getWidth(std::string const& portName, std:
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::getWidth()
//-----------------------------------------------------------------------------
-std::string PortAbstractionInterface::getWidth(std::string const& portName, General::InterfaceMode interfaceMode,
+std::string PortAbstractionInterface::getWidthExpression(std::string const& portName, General::InterfaceMode interfaceMode,
std::string const& systemGroup) const
{
QString signalWidth("");
@@ -922,6 +986,66 @@ std::string PortAbstractionInterface::getWidth(std::string const& portName, Gene
return signalWidth.toStdString();
}
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getWidthFormattedExpression()
+//-----------------------------------------------------------------------------
+std::string PortAbstractionInterface::getWidthFormattedExpression(int portIndex) const
+{
+ QSharedPointer selectedSignal = getSignal(portIndex);
+ if (!selectedSignal || !selectedSignal->wire_)
+ {
+ return std::string();
+ }
+
+ auto widthExpression = selectedSignal->wire_->getWidth();
+
+ if (widthExpression.isEmpty())
+ {
+ return widthExpression.toStdString();
+ }
+
+ return formattedValueFor(widthExpression).toStdString();
+}
+
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getWidthValue()
+//-----------------------------------------------------------------------------
+std::string PortAbstractionInterface::getWidthValue(int portIndex, int baseNumber /*= 0*/) const
+{
+ if (auto selectedSignal = getSignal(portIndex); selectedSignal && selectedSignal->wire_)
+ {
+ bool expressionIsValid = false;
+ auto value = parseExpressionToBaseNumber(
+ selectedSignal->wire_->getWidth(), baseNumber, &expressionIsValid).toStdString();
+
+ return expressionIsValid ? value : std::string("x");
+ }
+
+ return std::string("x");
+}
+
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getWidthValue()
+//-----------------------------------------------------------------------------
+std::string PortAbstractionInterface::getWidthValue(std::string const& portName,
+ General::InterfaceMode interfaceMode, std::string const& systemGroup) const
+{
+ QSharedPointer port = getPort(portName);
+ if (port && port->getWire() && interfaceMode != General::INTERFACE_MODE_COUNT)
+ {
+ auto width = port->getWire()->getWidth(interfaceMode, QString::fromStdString(systemGroup));
+ bool expressionOk = false;
+ auto widthAsValue = parseExpressionToBaseNumber(width, 0, &expressionOk);
+
+ if (expressionOk)
+ {
+ return widthAsValue.toStdString();
+ }
+ }
+
+ return std::string();
+}
+
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::setWidth()
//-----------------------------------------------------------------------------
@@ -1044,7 +1168,7 @@ bool PortAbstractionInterface::setPresence(int const& portIndex, std::string con
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::getDefaultValue()
//-----------------------------------------------------------------------------
-std::string PortAbstractionInterface::getDefaultValue(int const& portIndex) const
+std::string PortAbstractionInterface::getDefaultValueExpression(int const& portIndex) const
{
QSharedPointer selectedSignal = getSignal(portIndex);
if (selectedSignal && selectedSignal->abstraction_ && selectedSignal->abstraction_->hasWire())
@@ -1055,6 +1179,44 @@ std::string PortAbstractionInterface::getDefaultValue(int const& portIndex) cons
return std::string("");
}
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getDefaultValueFormattedExpression()
+//-----------------------------------------------------------------------------
+std::string PortAbstractionInterface::getDefaultValueFormattedExpression(int const& portIndex) const
+{
+ QSharedPointer selectedSignal = getSignal(portIndex);
+ if (!selectedSignal || !selectedSignal->wire_)
+ {
+ return std::string();
+ }
+
+ auto defaultValueExpression = selectedSignal->abstraction_->getDefaultValue();
+
+ if (defaultValueExpression.isEmpty())
+ {
+ return defaultValueExpression.toStdString();
+ }
+
+ return formattedValueFor(defaultValueExpression).toStdString();
+}
+
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getDefaultValueValue()
+//-----------------------------------------------------------------------------
+std::string PortAbstractionInterface::getDefaultValueValue(int const& portIndex, int baseNumber /*= 0*/) const
+{
+ if (auto selectedSignal = getSignal(portIndex); selectedSignal && selectedSignal->wire_)
+ {
+ bool expressionIsValid = false;
+ auto value = parseExpressionToBaseNumber(
+ selectedSignal->abstraction_->getDefaultValue(), baseNumber, &expressionIsValid).toStdString();
+
+ return expressionIsValid ? value : std::string("x");
+ }
+
+ return std::string("x");
+}
+
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::setDefaultValue()
//-----------------------------------------------------------------------------
@@ -1103,7 +1265,7 @@ bool PortAbstractionInterface::setDriverType(int const& portIndex, std::string c
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::()
//-----------------------------------------------------------------------------
-std::string PortAbstractionInterface::getBusWidthValue(int const& portIndex) const
+std::string PortAbstractionInterface::getBusWidthExpression(int const& portIndex) const
{
QSharedPointer selectedSignal = getSignal(portIndex);
if (selectedSignal && selectedSignal->transactional_)
@@ -1117,7 +1279,7 @@ std::string PortAbstractionInterface::getBusWidthValue(int const& portIndex) con
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::getBusWidthValue()
//-----------------------------------------------------------------------------
-std::string PortAbstractionInterface::getBusWidthValue(std::string const& portName,
+std::string PortAbstractionInterface::getBusWidthExpression(std::string const& portName,
std::string const& interfaceMode, std::string const& systemGroup) const
{
QString signalWidth("");
@@ -1133,6 +1295,44 @@ std::string PortAbstractionInterface::getBusWidthValue(std::string const& portNa
return signalWidth.toStdString();
}
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getBusWidthFormattedExpression()
+//-----------------------------------------------------------------------------
+std::string PortAbstractionInterface::getBusWidthFormattedExpression(int signalIndex) const
+{
+ QSharedPointer selectedSignal = getSignal(signalIndex);
+ if (!selectedSignal || !selectedSignal->transactional_)
+ {
+ return std::string();
+ }
+
+ auto busWidthExpression = selectedSignal->transactional_->getBusWidth();
+
+ if (busWidthExpression.isEmpty())
+ {
+ return busWidthExpression.toStdString();
+ }
+
+ return formattedValueFor(busWidthExpression).toStdString();
+}
+
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getBusWidthValue()
+//-----------------------------------------------------------------------------
+std::string PortAbstractionInterface::getBusWidthValue(int portIndex, int baseNumber /*= 0*/) const
+{
+ if (auto selectedSignal = getSignal(portIndex); selectedSignal && selectedSignal->transactional_)
+ {
+ bool expressionIsValid = false;
+ auto value = parseExpressionToBaseNumber(
+ selectedSignal->transactional_->getBusWidth(), baseNumber, &expressionIsValid).toStdString();
+
+ return expressionIsValid ? value : std::string("x");
+ }
+
+ return std::string("x");
+}
+
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::setBusWidth()
//-----------------------------------------------------------------------------
@@ -1150,6 +1350,19 @@ bool PortAbstractionInterface::setBusWidth(int const& portIndex, std::string con
return true;
}
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::transactionalHasValidBusWidth()
+//-----------------------------------------------------------------------------
+bool PortAbstractionInterface::transactionalHasValidBusWidth(int portIndex) const
+{
+ if (auto signal = getSignal(portIndex); portValidator_ && signal)
+ {
+ return portValidator_->transactionalHasValidBusWidth(signal->transactional_);
+ }
+
+ return false;
+}
+
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::getInitiative()
//-----------------------------------------------------------------------------
@@ -1464,7 +1677,7 @@ bool PortAbstractionInterface::setPayloadExtension(int const& portIndex, std::st
}
//-----------------------------------------------------------------------------
-// Function: PortAbstractionInterface::addWirePort()
+// Function: PortAbstractionInterface:: WirePort()
//-----------------------------------------------------------------------------
void PortAbstractionInterface::addWirePort(std::string const& newPortName)
{
@@ -1737,6 +1950,14 @@ Qualifier::Attribute PortAbstractionInterface::getQualifierAttributeType(std::st
}
}
+//-----------------------------------------------------------------------------
+// Function: PortAbstractionInterface::getAllReferencesToIdInItem()
+//-----------------------------------------------------------------------------
+int PortAbstractionInterface::getAllReferencesToIdInItem(const std::string&, std::string const&) const
+{
+ return 0; /* AbstractionPortsModel uses getAllReferencesToIdInRow() instead */
+}
+
//-----------------------------------------------------------------------------
// Function: PortAbstractionInterface::removeSignal()
//-----------------------------------------------------------------------------
diff --git a/KactusAPI/interfaces/component/BusInterfaceInterfaceFactory.cpp b/KactusAPI/interfaces/component/BusInterfaceInterfaceFactory.cpp
index e3d68caff..9a7d1676b 100644
--- a/KactusAPI/interfaces/component/BusInterfaceInterfaceFactory.cpp
+++ b/KactusAPI/interfaces/component/BusInterfaceInterfaceFactory.cpp
@@ -201,7 +201,7 @@ PortMapInterface* BusInterfaceInterfaceFactory::Details::createPortMapInterface(
PortsInterface* physicalPortInterface(new PortsInterface(portValidator, expressionParser, expressionFormatter));
physicalPortInterface->setPorts(component->getPorts());
- PortAbstractionInterface* logicalPortInterface(new PortAbstractionInterface());
+ PortAbstractionInterface* logicalPortInterface(new PortAbstractionInterface(expressionParser, expressionFormatter));
PortMapInterface* portMapInterface(new PortMapInterface(
portMapValidator, expressionParser, expressionFormatter, physicalPortInterface, logicalPortInterface));
diff --git a/KactusAPI/interfaces/component/PortMapInterface.cpp b/KactusAPI/interfaces/component/PortMapInterface.cpp
index db22abae1..2ffdcbd26 100644
--- a/KactusAPI/interfaces/component/PortMapInterface.cpp
+++ b/KactusAPI/interfaces/component/PortMapInterface.cpp
@@ -1158,7 +1158,8 @@ bool PortMapInterface::connectPorts(std::string const& logicalPortName, std::str
QSharedPointer newMappedLogical = newPortMap->getLogicalPort();
QString logicalWireWidth(QString::fromStdString(
- logicalPortInterface_->getWidth(logicalPortName, interfaceMode, systemGroup)));
+ logicalPortInterface_->getWidthValue(logicalPortName, General::str2Interfacemode(QString::fromStdString(interfaceMode),
+ General::InterfaceMode::INTERFACE_MODE_COUNT), systemGroup)));
if (!logicalWireWidth.isEmpty())
{
qint64 logicalSize = parseExpressionToDecimal(logicalWireWidth).toInt();
diff --git a/KactusAPI/library/DocumentValidator.cpp b/KactusAPI/library/DocumentValidator.cpp
index 792354455..fdcf58f48 100644
--- a/KactusAPI/library/DocumentValidator.cpp
+++ b/KactusAPI/library/DocumentValidator.cpp
@@ -29,7 +29,7 @@
//-----------------------------------------------------------------------------
DocumentValidator::DocumentValidator(LibraryInterface* library) :
library_(library),
- abstractionValidator_(library_, QSharedPointer(new SystemVerilogExpressionParser())),
+ abstractionValidator_(library_, QSharedPointer(new IPXactSystemVerilogParser(absDefParameterFinder_))),
busValidator_(library_, QSharedPointer(new SystemVerilogExpressionParser())),
designValidator_(QSharedPointer(new IPXactSystemVerilogParser(designValidatorFinder_)), library_),
designConfigurationValidator_(QSharedPointer(new SystemVerilogExpressionParser()), library_),
@@ -45,7 +45,8 @@ bool DocumentValidator::validate(QSharedPointer document)
{
VLNV::IPXactType documentType = document->getVlnv().getType();
if (documentType == VLNV::ABSTRACTIONDEFINITION)
- {
+ {
+ absDefParameterFinder_->setParameterList(document->getParameters());
return abstractionValidator_.validate(document.dynamicCast());
}
else if (documentType == VLNV::BUSDEFINITION)
diff --git a/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceCounter.h b/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceCounter.h
index 4681b029a..68f1b1bb9 100644
--- a/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceCounter.h
+++ b/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceCounter.h
@@ -35,8 +35,8 @@ class AbsDefParameterReferenceCounter : public ParameterReferenceCounter
*/
AbsDefParameterReferenceCounter(QSharedPointer parameterFinder, QSharedPointer absDef);
- AbsDefParameterReferenceCounter(AbsDefParameterReferenceCounter& other) = delete;
- AbsDefParameterReferenceCounter& operator=(AbsDefParameterReferenceCounter& other) = delete;
+ AbsDefParameterReferenceCounter(AbsDefParameterReferenceCounter const& other) = delete;
+ AbsDefParameterReferenceCounter& operator=(AbsDefParameterReferenceCounter const& other) = delete;
virtual ~AbsDefParameterReferenceCounter() = default;
diff --git a/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.cpp b/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.cpp
index 3ebbff8eb..1a7e33d5f 100644
--- a/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.cpp
+++ b/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.cpp
@@ -86,32 +86,48 @@ void AbsDefParameterReferenceTree::setupTree()
for (auto const& portWithWire : absDef_->getPortsWithWire())
{
auto wireAbstraction = portWithWire->getWire();
-
- auto singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);
+ QTreeWidgetItem* singleWirePortItem = nullptr;
if (portWithWire->getDefaultValue().contains(targetId))
{
+ // Create wire port item only if necessary
+ singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);
createItem(QStringLiteral("Default value"), portWithWire->getDefaultValue(), singleWirePortItem);
}
if (wireAbstraction->hasMode(initiatorMode, QString()) &&
wireAbstraction->getInitiatorPort()->getWidth().contains(targetId))
{
+ if (!singleWirePortItem)
+ {
+ singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);
+ }
+
auto initiatorItem = createMiddleItem(QStringLiteral("Initiator"), singleWirePortItem);
- createItem(QStringLiteral("Width"), targetId, initiatorItem);
+ createItem(QStringLiteral("Width"), wireAbstraction->getInitiatorPort()->getWidth(), initiatorItem);
}
if (wireAbstraction->hasMode(targetMode, QString()) &&
wireAbstraction->getTargetPort()->getWidth().contains(targetId))
{
+ if (!singleWirePortItem)
+ {
+ singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);
+ }
+
auto targetItem = createMiddleItem(QStringLiteral("Target"), singleWirePortItem);
- createItem(QStringLiteral("Width"), targetId, targetItem);
+ createItem(QStringLiteral("Width"), wireAbstraction->getTargetPort()->getWidth(), targetItem);
}
for (auto const& systemPort : *wireAbstraction->getSystemPorts())
{
if (systemPort->getWidth().contains(targetId))
{
+ if (!singleWirePortItem)
+ {
+ singleWirePortItem = createMiddleItem(portWithWire->name(), wirePortsItem);
+ }
+
auto systemItem = createMiddleItem(tr("System (%1)").arg(systemPort->getSystemGroup()), singleWirePortItem);
createItem(QStringLiteral("Width"), systemPort->getWidth(), systemItem);
}
@@ -127,26 +143,39 @@ void AbsDefParameterReferenceTree::setupTree()
{
auto transactionalAbstraction = portWithTransactional->getTransactional();
- auto singleTransactionalPortItem = createMiddleItem(portWithTransactional->name(), transactionalPortsItem);
+ QTreeWidgetItem* singleTransactionalPortItem = nullptr;
if (transactionalAbstraction->hasMode(initiatorMode, QString()) &&
transactionalAbstraction->getInitiatorPort()->getBusWidth().contains(targetId))
{
+ singleTransactionalPortItem = createMiddleItem(portWithTransactional->name(), transactionalPortsItem);
+
auto initiatorItem = createMiddleItem(QStringLiteral("Initiator"), singleTransactionalPortItem);
- createItem(QStringLiteral("Bus width"), targetId, initiatorItem);
+ createItem(QStringLiteral("Bus width"),
+ transactionalAbstraction->getInitiatorPort()->getBusWidth(), initiatorItem);
}
if (transactionalAbstraction->hasMode(targetMode, QString()) &&
transactionalAbstraction->getTargetPort()->getBusWidth().contains(targetId))
{
+ if (!singleTransactionalPortItem)
+ {
+ singleTransactionalPortItem = createMiddleItem(portWithTransactional->name(), transactionalPortsItem);
+ }
+
auto targetItem = createMiddleItem(QStringLiteral("Target"), singleTransactionalPortItem);
- createItem(QStringLiteral("Bus width"), targetId, targetItem);
+ createItem(QStringLiteral("Bus width"), transactionalAbstraction->getTargetPort()->getBusWidth(), targetItem);
}
for (auto const& systemPort : *transactionalAbstraction->getSystemPorts())
{
if (systemPort->getBusWidth().contains(targetId))
{
+ if (!singleTransactionalPortItem)
+ {
+ singleTransactionalPortItem = createMiddleItem(portWithTransactional->name(), transactionalPortsItem);
+ }
+
auto systemItem = createMiddleItem(tr("System (%1)").arg(systemPort->getSystemGroup()), singleTransactionalPortItem);
createItem(QStringLiteral("Bus width"), systemPort->getBusWidth(), systemItem);
}
diff --git a/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.h b/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.h
index 3177fe449..bc574720a 100644
--- a/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.h
+++ b/editors/AbstractionDefinitionEditor/AbsDefParameterReferenceTree.h
@@ -36,8 +36,8 @@ class AbsDefParameterReferenceTree : public ParameterReferenceTree
virtual ~AbsDefParameterReferenceTree() = default;
- AbsDefParameterReferenceTree(AbsDefParameterReferenceTree& other) = delete;
- AbsDefParameterReferenceTree& operator=(AbsDefParameterReferenceTree& other) = delete;
+ AbsDefParameterReferenceTree(AbsDefParameterReferenceTree const& other) = delete;
+ AbsDefParameterReferenceTree& operator=(AbsDefParameterReferenceTree const& other) = delete;
/*!
* Set a new abstraction definition.
diff --git a/editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.cpp b/editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.cpp
index 24f7100ab..b4154bd15 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.cpp
+++ b/editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.cpp
@@ -18,7 +18,7 @@
#include
#include
-#include
+#include
#include
#include
@@ -42,9 +42,10 @@ AbstractionDefinitionEditor::AbstractionDefinitionEditor(QWidget *parent, Librar
TabDocument(parent, libHandler, DOC_PROTECTION_SUPPORT),
absDef_(absDef),
expressionFormatter_(new ExpressionFormatter(absDefParameterFinder_)),
-absDefGroup_(revision, absDef, expressionFormatter_, absDefParameterFinder_, libHandler,
+expressionParser_(new IPXactSystemVerilogParser(absDefParameterFinder_)),
+portValidator_(new PortAbstractionValidator(libHandler, expressionParser_)),
+absDefGroup_(revision, absDef, expressionFormatter_, expressionParser_, absDefParameterFinder_, libHandler,
createPortAbstractionInterface(), createPortAbstractionInterface(), this),
-expressionParser_(new SystemVerilogExpressionParser()),
absDefinitionValidator_(new AbstractionDefinitionValidator(libHandler, expressionParser_)),
referenceCounter_(new AbsDefParameterReferenceCounter(absDefParameterFinder_, absDef)),
parameterReferenceTree_(new AbsDefParameterReferenceTree(absDef, referenceCounter_, expressionFormatter_)),
@@ -85,7 +86,7 @@ referenceTreeWindow_(new ParameterReferenceTreeWindow(parameterReferenceTree_))
referenceCounter_.data(), SLOT(decreaseReferenceCount(QString)), Qt::UniqueConnection);
connect(&absDefGroup_, SIGNAL(openReferenceTree(QString const&, QString const&)),
- referenceTreeWindow_, SLOT(openReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);
+ this, SLOT(onOpenReferenceTree(QString const&, QString const&)), Qt::UniqueConnection);
connect(&absDefGroup_, SIGNAL(recalculateReferencesToParameters(QVector const&, AbstractParameterInterface*)),
referenceCounter_.data(), SLOT(recalculateReferencesToParameters(QVector const&, AbstractParameterInterface*)), Qt::UniqueConnection);
@@ -232,6 +233,16 @@ void AbstractionDefinitionEditor::showEvent(QShowEvent* event)
}
}
+//-----------------------------------------------------------------------------
+// Function: AbstractionDefinitionEditor::onOpenReferenceTree()
+//-----------------------------------------------------------------------------
+void AbstractionDefinitionEditor::onOpenReferenceTree(QString const& parameterID, QString const& parameterName)
+{
+ // Refresh references before opening window.
+ parameterReferenceTree_->setAbsDef(absDef_);
+ referenceTreeWindow_->openReferenceTree(parameterID, parameterName);
+}
+
//-----------------------------------------------------------------------------
// Function: AbstractionDefinitionEditor::setupLayout()
//-----------------------------------------------------------------------------
@@ -252,6 +263,7 @@ void AbstractionDefinitionEditor::setupLayout()
//-----------------------------------------------------------------------------
PortAbstractionInterface* AbstractionDefinitionEditor::createPortAbstractionInterface()
{
- PortAbstractionInterface* portInterface(new PortAbstractionInterface());
+ PortAbstractionInterface* portInterface(new PortAbstractionInterface(expressionParser_, expressionFormatter_));
+ portInterface->setPortAbstractionValidator(portValidator_);
return portInterface;
}
diff --git a/editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.h b/editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.h
index 09cf5ab12..b6282dc99 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.h
+++ b/editors/AbstractionDefinitionEditor/AbstractionDefinitionEditor.h
@@ -16,6 +16,7 @@
#include
#include
+#include
#include
#include
@@ -26,7 +27,7 @@
class AbstractionDefinitionValidator;
class BusDefinitionValidator;
-class ExpressionParser;
+class IPXactSystemVerilogParser;
class PortAbstractionInterface;
class ExpressionFormatter;
class AbsDefParameterReferenceCounter;
@@ -135,6 +136,10 @@ public slots:
*/
virtual void showEvent(QShowEvent* event);
+private slots:
+
+ void onOpenReferenceTree(QString const& parameterID, QString const& parameterName);
+
private:
/*!
@@ -166,12 +171,15 @@ public slots:
//! The expression formatter to use in the parameter reference tree.
QSharedPointer expressionFormatter_;
+ //! Parser for expressions in definitions.
+ QSharedPointer expressionParser_;
+
+ //! Validator for port abstractions.
+ QSharedPointer portValidator_;
+
//! Group containing elements to edit abstraction definition.
AbsDefGroup absDefGroup_;
- //! Parser for expressions in definitions.
- QSharedPointer expressionParser_;
-
//! Validator for abstraction definition.
QSharedPointer absDefinitionValidator_;
diff --git a/editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.cpp b/editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.cpp
index 0c2e4b5cc..b5d1d1ade 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.cpp
+++ b/editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.cpp
@@ -30,15 +30,14 @@
//-----------------------------------------------------------------------------
// Function: AbstractionPortsDelegate::AbstractionPortsDelegate()
//-----------------------------------------------------------------------------
-AbstractionPortsDelegate::AbstractionPortsDelegate(LibraryInterface* libraryAcces,
- Document::Revision stdRevision, QObject *parent):
-EnumerationEditorConstructorDelegate(parent),
+AbstractionPortsDelegate::AbstractionPortsDelegate(QAbstractItemModel* parametersModel,
+ QSharedPointer parameterFinder, LibraryInterface* libraryAcces,
+ Document::Revision stdRevision, QObject* parent) :
+ExpressionDelegate(parametersModel, parameterFinder, parent),
stdRevision_(stdRevision),
libraryAccess_(libraryAcces),
busDefinition_(0)
{
- setHideCheckAll(true);
-
setModeOptions();
}
@@ -48,13 +47,7 @@ busDefinition_(0)
QWidget* AbstractionPortsDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option,
const QModelIndex& index ) const
{
- if (index.column() == LogicalPortColumns::BUSWIDTH)
- {
- QLineEdit* line = new QLineEdit(parent);
- connect(line, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
- return line;
- }
- else if (index.column() == LogicalPortColumns::MODE)
+ if (index.column() == LogicalPortColumns::MODE)
{
QComboBox* box = new QComboBox(parent);
@@ -97,16 +90,17 @@ QWidget* AbstractionPortsDelegate::createEditor(QWidget* parent, QStyleOptionVie
connect(box, SIGNAL(destroyed()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
return box;
}
- else if (index.column() == LogicalPortColumns::QUALIFIER && stdRevision_ == Document::Revision::Std22)
+ else if (index.column() == LogicalPortColumns::QUALIFIER)
{
- QualifierEditor* qualifierEditor = new QualifierEditor(parent);
+ QualifierEditor* qualifierEditor = new QualifierEditor(stdRevision_, parent);
+ qualifierEditor->setupEditor(getQualifierList());
connect(qualifierEditor, SIGNAL(finishEditing()), this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
connect(qualifierEditor, SIGNAL(cancelEditing()), this, SLOT(onEditingCanceled()), Qt::UniqueConnection);
return qualifierEditor;
}
else
{
- return EnumerationEditorConstructorDelegate::createEditor(parent, option, index);
+ return ExpressionDelegate::createEditor(parent, option, index);
}
}
@@ -144,21 +138,21 @@ void AbstractionPortsDelegate::setEditorData(QWidget* editor, QModelIndex const&
box->setCurrentText(text);
}
}
- else if (index.column() == LogicalPortColumns::QUALIFIER && stdRevision_ == Document::Revision::Std22)
+ else if (index.column() == LogicalPortColumns::QUALIFIER)
{
QualifierEditor* qualifierEditor = qobject_cast(editor);
Q_ASSERT_X(qualifierEditor, "AbstractionPortsDelegate::setEditorData",
"Type conversion failed for QualifierEditor");
- auto allQualifiers = getAvailableItems();
- auto setQualifier = index.data(Qt::UserRole).value();
-
- qualifierEditor->setupEditor(allQualifiers, setQualifier.activeQualifiers_, setQualifier.attributes_);
+ auto setQualifiers = index.data(Qt::EditRole).value();
+
+ // Hide all attributes before showing only set attributes. Done here to make editor the right width.
+ qualifierEditor->hideAllAttributes();
+ qualifierEditor->setupEditorData(setQualifiers.activeQualifiers_, setQualifiers.attributes_);
}
-
else
{
- EnumerationEditorConstructorDelegate::setEditorData(editor, index);
+ ExpressionDelegate::setEditorData(editor, index);
}
}
@@ -167,8 +161,7 @@ void AbstractionPortsDelegate::setEditorData(QWidget* editor, QModelIndex const&
//-----------------------------------------------------------------------------
bool AbstractionPortsDelegate::editorIsLineEditor(int indexColumn) const
{
- return indexColumn == LogicalPortColumns::NAME || indexColumn == LogicalPortColumns::WIDTH ||
- indexColumn == LogicalPortColumns::BUSWIDTH || indexColumn == LogicalPortColumns::DESCRIPTION ||
+ return indexColumn == LogicalPortColumns::NAME ||
indexColumn == LogicalPortColumns::PAYLOADNAME || indexColumn == LogicalPortColumns::PAYLOADEXTENSION;
}
@@ -202,7 +195,7 @@ void AbstractionPortsDelegate::setModelData(QWidget* editor, QAbstractItemModel*
model->setData(index, selector->currentText(), Qt::EditRole);
}
- else if (index.column() == LogicalPortColumns::QUALIFIER && stdRevision_ == Document::Revision::Std22)
+ else if (index.column() == LogicalPortColumns::QUALIFIER)
{
QualifierEditor* qualifierEditor = qobject_cast(editor);
Q_ASSERT_X(qualifierEditor, "AbstractionPortsDelegate::setModelData", "Type conversion failed for qualifier editor");
@@ -211,7 +204,7 @@ void AbstractionPortsDelegate::setModelData(QWidget* editor, QAbstractItemModel*
}
else
{
- EnumerationEditorConstructorDelegate::setModelData(editor, model, index);
+ ExpressionDelegate::setModelData(editor, model, index);
}
}
@@ -254,12 +247,12 @@ void AbstractionPortsDelegate::setBusDef(QSharedPointer bus
//-----------------------------------------------------------------------------
void AbstractionPortsDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
- if (stdRevision_ != Document::Revision::Std22 || index.column() != LogicalPortColumns::QUALIFIER)
+ if (index.column() != LogicalPortColumns::QUALIFIER)
{
- return EnumerationEditorConstructorDelegate::updateEditorGeometry(editor, option, index);
+ return ExpressionDelegate::updateEditorGeometry(editor, option, index);
}
- int enumerationCount = getAvailableItems().count();
+ int enumerationCount = getQualifierList().count();
int editorMinimumHeight = 25 * (enumerationCount + 2);
int editorWidth = editor->sizeHint().width();
@@ -329,43 +322,6 @@ QStringList AbstractionPortsDelegate::getQualifierList() const
return list;
}
-//-----------------------------------------------------------------------------
-// Function: AbstractionPortsDelegate::isEnumerationEditorColumn()
-//-----------------------------------------------------------------------------
-bool AbstractionPortsDelegate::isEnumerationEditorColumn(QModelIndex const& index) const
-{
- if (index.column() == LogicalPortColumns::QUALIFIER)
- {
- return true;
- }
-
- return false;
-}
-
-//-----------------------------------------------------------------------------
-// Function: AbstractionPortsDelegate::getCurrentSelection()
-//-----------------------------------------------------------------------------
-QStringList AbstractionPortsDelegate::getCurrentSelection(QModelIndex const& index) const
-{
- return index.data().toString().split(" ");
-}
-
-//-----------------------------------------------------------------------------
-// Function: AbstractionPortsDelegate::getAvailableItems()
-//-----------------------------------------------------------------------------
-QStringList AbstractionPortsDelegate::getAvailableItems() const
-{
- return getQualifierList();
-}
-
-//-----------------------------------------------------------------------------
-// Function: AbstractionPortsDelegate::setEnumerationDataToModel()
-//-----------------------------------------------------------------------------
-void AbstractionPortsDelegate::setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const
-{
- model->setData(index, selectedItems);
-}
-
//-----------------------------------------------------------------------------
// Function: AbstractionPortsDelegate::setModeOptions()
//-----------------------------------------------------------------------------
@@ -380,3 +336,11 @@ void AbstractionPortsDelegate::setModeOptions()
modeOptions_ = { "master", "slave", "system" };
}
}
+
+//-----------------------------------------------------------------------------
+// Function: AbstractionPortsDelegate::descriptionColumn()
+//-----------------------------------------------------------------------------
+int AbstractionPortsDelegate::descriptionColumn() const
+{
+ return LogicalPortColumns::DESCRIPTION;
+}
diff --git a/editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.h b/editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.h
index b33454b92..0911ab264 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.h
+++ b/editors/AbstractionDefinitionEditor/AbstractionPortsDelegate.h
@@ -12,7 +12,7 @@
#ifndef ABSTRACTIONPORTSDELEGATE_H
#define ABSTRACTIONPORTSDELEGATE_H
-#include
+#include
#include
@@ -26,7 +26,7 @@ class QualifierEditor;
//-----------------------------------------------------------------------------
//! Master delegate for abstraction definition wire and transactional ports.
//-----------------------------------------------------------------------------
-class AbstractionPortsDelegate : public EnumerationEditorConstructorDelegate
+class AbstractionPortsDelegate : public ExpressionDelegate
{
Q_OBJECT
@@ -35,11 +35,14 @@ class AbstractionPortsDelegate : public EnumerationEditorConstructorDelegate
/*!
* The constructor.
*
+ * @param [in] parametersModel The parameter completer model to use.
+ * @param [in] parameterFinder The parameter finder to use.
* @param [in] libraryAccess Interface to the library.
* @param [in] stdRevision The revision of the standard used by the abstraction definition.
* @param [in] parent The owner of this instance
*/
- AbstractionPortsDelegate(LibraryInterface* libraryAcces, Document::Revision stdRevision, QObject *parent);
+ AbstractionPortsDelegate(QAbstractItemModel* parametersModel, QSharedPointer parameterFinder,
+ LibraryInterface* libraryAcces, Document::Revision stdRevision, QObject *parent);
/*!
* The destructor.
@@ -138,43 +141,16 @@ protected slots:
AbstractionPortsDelegate& operator=(const AbstractionPortsDelegate& other);
/*!
- * Check if the column is used for enumerations.
- *
- * @param [in] index The selected index.
- *
- * @return True, if the column is used for editing enumerations, false otherwise.
- */
- virtual bool isEnumerationEditorColumn(QModelIndex const& index) const override final;
-
- /*!
- * The list of currently selected enumerations in the selected item.
- *
- * @param [in] index Index of the selected item.
- *
- * @return List of currently selected enumerations.
- */
- virtual QStringList getCurrentSelection(QModelIndex const& index) const override final;
-
- /*!
- * Get the list of the available enumerations.
- *
- * @return List of the available enumerations.
- */
- virtual QStringList getAvailableItems() const override final;
-
- /*!
- * Set the selected enumerations to the selected item.
- *
- * @param [in] index Model index identifying the item that's data is to be saved.
- * @param [in] model Model that contains the data structure where data is to be saved to.
- * @param [in] selectedItems List of the selected enumerations.
+ * Set the interface mode options depending on std revision.
*/
- virtual void setEnumerationDataToModel(QModelIndex const& index, QAbstractItemModel* model, QStringList const& selectedItems) const override final;
+ void setModeOptions();
/*!
- * Set the interface mode options depending on std revision.
+ * Get the index of the description column.
+ *
+ * @return The description column index.
*/
- void setModeOptions();
+ int descriptionColumn() const final;
//-----------------------------------------------------------------------------
// Data.
diff --git a/editors/AbstractionDefinitionEditor/AbstractionPortsEditor.cpp b/editors/AbstractionDefinitionEditor/AbstractionPortsEditor.cpp
index db578c6c7..a3f128bcc 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionPortsEditor.cpp
+++ b/editors/AbstractionDefinitionEditor/AbstractionPortsEditor.cpp
@@ -21,13 +21,16 @@
#include "AbstractionTransactionalPortsDelegate.h"
#include "LogicalPortColumns.h"
+#include
+
#include
#include
//-----------------------------------------------------------------------------
// Function: AbstractionPortsEditor::AbstractionPortsEditor()
//-----------------------------------------------------------------------------
-AbstractionPortsEditor::AbstractionPortsEditor(LibraryInterface* libraryAccess,
+AbstractionPortsEditor::AbstractionPortsEditor(QAbstractItemModel* parametersModel,
+ QSharedPointer parameterFinder, LibraryInterface* libraryAccess,
PortAbstractionInterface* portInterface, Document::Revision stdRevision, AbstractionPortsModel* portModel,
LogicalPortColumns::AbstractionType type, QWidget* parent):
QWidget(parent),
@@ -39,12 +42,12 @@ portDelegate_(nullptr)
if (type == LogicalPortColumns::AbstractionType::WIRE)
{
portProxy_ = new AbstractionWirePortsSortFilter(portInterface, this);
- portDelegate_ = new AbstractionWirePortsDelegate(libraryAccess, stdRevision, this);
+ portDelegate_ = new AbstractionWirePortsDelegate(parametersModel, parameterFinder, libraryAccess, stdRevision, this);
}
else
{
portProxy_ = new AbstractionTransactionalPortsSortFilter(portInterface, this);
- portDelegate_ = new AbstractionTransactionalPortsDelegate(libraryAccess, stdRevision, this);
+ portDelegate_ = new AbstractionTransactionalPortsDelegate(parametersModel, parameterFinder, libraryAccess, stdRevision, this);
}
portProxy_->setSourceModel(portModel_);
@@ -84,6 +87,12 @@ portDelegate_(nullptr)
connect(portModel_, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)),
this, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)), Qt::UniqueConnection);
+ connect(portModel_, SIGNAL(increaseReferences(QString const&)), this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);
+ connect(portModel_, SIGNAL(decreaseReferences(QString const&)), this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);
+
+ connect(portDelegate_, SIGNAL(increaseReferences(QString)), this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);
+ connect(portDelegate_, SIGNAL(decreaseReferences(QString)), this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);
+
if (type == LogicalPortColumns::AbstractionType::WIRE)
{
connect(&portView_, SIGNAL(addItem(const QModelIndex&)),
diff --git a/editors/AbstractionDefinitionEditor/AbstractionPortsEditor.h b/editors/AbstractionDefinitionEditor/AbstractionPortsEditor.h
index a6ef87c52..2ba0b18ef 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionPortsEditor.h
+++ b/editors/AbstractionDefinitionEditor/AbstractionPortsEditor.h
@@ -29,6 +29,8 @@ class AbstractionPortsDelegate;
class BusDefinition;
class PortAbstractionInterface;
class LibraryInterface;
+class QAbstractItemModel;
+class ParameterFinder;
//-----------------------------------------------------------------------------
//! Editor for the ports of an abstraction definition.
@@ -42,6 +44,8 @@ class AbstractionPortsEditor : public QWidget
/*!
* The constructor.
*
+ * @param [in] parametersModel The parameter completer model to use.
+ * @param [in] parameterFinder The parameter finder to use.
* @param [in] libraryAccess Interface to the library.
* @param [in] portInterface Interface for accessing port abstractions.
* @param [in] stdRevision The revision of the standard used by the abstraction definition.
@@ -49,7 +53,8 @@ class AbstractionPortsEditor : public QWidget
* @param [in] type The type of ports the editor is targeted for: wire or transactional.
* @param [in] parent The owner of the editor.
*/
- AbstractionPortsEditor(LibraryInterface* libraryAccess, PortAbstractionInterface* portInterface,
+ AbstractionPortsEditor(QAbstractItemModel* parametersModel, QSharedPointer parameterFinder,
+ LibraryInterface* libraryAccess, PortAbstractionInterface* portInterface,
Document::Revision stdRevision, AbstractionPortsModel* portModel,
LogicalPortColumns::AbstractionType type, QWidget* parent);
@@ -102,6 +107,20 @@ class AbstractionPortsEditor : public QWidget
*/
void portRemoved(QString const& portName, General::InterfaceMode const mode);
+ /*!
+ * Increase the amount of references to a parameter corresponding to the id.
+ *
+ * @param [in] id The id of the parameter being searched for.
+ */
+ void increaseReferences(QString id);
+
+ /*!
+ * Decrease the amount of references to a parameter corresponding to the id.
+ *
+ * @param [in] id The id of the parameter being searched for.
+ */
+ void decreaseReferences(QString id);
+
private slots:
/*!
diff --git a/editors/AbstractionDefinitionEditor/AbstractionPortsModel.cpp b/editors/AbstractionDefinitionEditor/AbstractionPortsModel.cpp
index 7bf15e923..c818e3f54 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionPortsModel.cpp
+++ b/editors/AbstractionDefinitionEditor/AbstractionPortsModel.cpp
@@ -32,6 +32,7 @@
#include
#include
+#include
namespace {
@@ -54,17 +55,20 @@ namespace {
//-----------------------------------------------------------------------------
// Function: AbstractionPortsModel::AbstractionPortsModel()
//-----------------------------------------------------------------------------
-AbstractionPortsModel::AbstractionPortsModel(LibraryInterface* libraryAccess,
+AbstractionPortsModel::AbstractionPortsModel(QSharedPointer parameterFinder,
+ QSharedPointer expressionParser,
+ LibraryInterface* libraryAccess,
PortAbstractionInterface* portInterface,
PortAbstractionInterface* extendInterface,
- QObject *parent):
-QAbstractTableModel(parent),
+ QObject *parent) :
+ReferencingTableModel(parameterFinder, parent),
+ParameterizableTable(parameterFinder),
busDefinition_(),
libraryAccess_(libraryAccess),
portInterface_(portInterface),
extendInterface_(extendInterface)
{
-
+ setExpressionParser(expressionParser);
}
//-----------------------------------------------------------------------------
@@ -144,7 +148,7 @@ QVariant AbstractionPortsModel::headerData(int section, Qt::Orientation orientat
}
else if (section == LogicalPortColumns::WIDTH)
{
- return tr("Width");
+ return tr("Width") + getExpressionSymbol();
}
else if (section == LogicalPortColumns::DIRECTION)
{
@@ -164,7 +168,7 @@ QVariant AbstractionPortsModel::headerData(int section, Qt::Orientation orientat
}
else if (section == LogicalPortColumns::DEFAULT_VALUE)
{
- return tr("Default value");
+ return tr("Default value") + getExpressionSymbol();
}
else if (section == LogicalPortColumns::DRIVER)
{
@@ -184,7 +188,7 @@ QVariant AbstractionPortsModel::headerData(int section, Qt::Orientation orientat
}
else if (section == LogicalPortColumns::BUSWIDTH)
{
- return tr("Bus width");
+ return tr("Bus width") + getExpressionSymbol();
}
else if (section == LogicalPortColumns::PROTOCOLTYPE)
{
@@ -215,133 +219,68 @@ QVariant AbstractionPortsModel::data(QModelIndex const& index, int role) const
{
if (!index.isValid() || index.row() < 0 || index.row() >= portInterface_->itemCount())
{
- return QVariant();
+ return QVariant();
}
-
- if (role == Qt::DisplayRole || role == Qt::ToolTipRole)
- {
- if (index.column() == LogicalPortColumns::NAME)
- {
- QString logicalName = QString::fromStdString(portInterface_->getIndexedItemName(index.row()));
- if (logicalName.isEmpty())
- {
- return "unnamed";
- }
- else
- {
- return logicalName;
- }
- }
- else if (index.column() == LogicalPortColumns::QUALIFIER)
- {
- QStringList qualifierList;
- for (auto qualifier : portInterface_->getQualifierStringList(index.row()))
- {
- qualifierList.append(QString::fromStdString(qualifier));
- }
- return qualifierList.join(", ");
- }
- else if (index.column() == LogicalPortColumns::MATCH)
- {
- return General::bool2Str(portInterface_->getMatch(index.row()));
- }
- else if (index.column() == LogicalPortColumns::WIDTH)
- {
- return QString::fromStdString(portInterface_->getWidth(index.row()));
- }
- else if (index.column() == LogicalPortColumns::DIRECTION)
- {
- return QString::fromStdString(portInterface_->getDirectionString(index.row()));
- }
- else if (index.column() == LogicalPortColumns::MODE)
- {
- return QString::fromStdString(portInterface_->getModeString(index.row()));
- }
- else if (index.column() == LogicalPortColumns::SYSTEM_GROUP)
- {
- return QString::fromStdString(portInterface_->getSystemGroup(index.row()));
- }
- else if (index.column() == LogicalPortColumns::PRESENCE)
- {
- return QString::fromStdString(portInterface_->getPresenceString(index.row()));
- }
- else if (index.column() == LogicalPortColumns::KIND)
- {
- return QString::fromStdString(portInterface_->getKind(index.row()));
- }
- else if (index.column() == LogicalPortColumns::INITIATIVE)
- {
- return QString::fromStdString(portInterface_->getInitiative(index.row()));
- }
- else if (index.column() == LogicalPortColumns::BUSWIDTH)
- {
- return QString::fromStdString(portInterface_->getBusWidthValue(index.row()));
- }
- else if (index.column() == LogicalPortColumns::DEFAULT_VALUE)
+ if (role == Qt::DisplayRole)
+ {
+ if (isValidExpressionColumn(index))
{
- return QString::fromStdString(portInterface_->getDefaultValue(index.row()));
+ return formattedExpressionForIndex(index);
}
- else if (index.column() == LogicalPortColumns::DRIVER)
+ else if (index.column() == LogicalPortColumns::DESCRIPTION)
{
- return QString::fromStdString(portInterface_->getDriverString(index.row()));
+ return valueForIndex(index).toString().replace(QRegularExpression("\n.*$",
+ QRegularExpression::DotMatchesEverythingOption), "...");
}
- else if (index.column() == LogicalPortColumns::DESCRIPTION)
+ else
{
- std::string portName = portInterface_->getIndexedItemName(index.row());
- return QString::fromStdString(portInterface_->getDescription(portName));
+ return valueForIndex(index);
}
- else if ((index.column() == LogicalPortColumns::PROTOCOLTYPE ||
- index.column() == LogicalPortColumns::PAYLOADNAME ||
- index.column() == LogicalPortColumns::PAYLOADTYPE ||
- index.column() == LogicalPortColumns::PAYLOADEXTENSION) &&
- portInterface_->hasProtocol(index.row()))
+ }
+
+ else if (role == Qt::EditRole)
+ {
+ if (index.column() == LogicalPortColumns::QUALIFIER)
{
- if (index.column() == LogicalPortColumns::PROTOCOLTYPE)
- {
- return QString::fromStdString(portInterface_->getProtocolType(index.row()));
- }
- else if (index.column() == LogicalPortColumns::PAYLOADNAME)
- {
- return QString::fromStdString(portInterface_->getPayloadName(index.row()));
- }
- else if (index.column() == LogicalPortColumns::PAYLOADTYPE)
+ QStringList qualifierList;
+ for (auto const& qualifier : portInterface_->getQualifierStringList(index.row()))
{
- return QString::fromStdString(portInterface_->getPayloadType(index.row()));
+ qualifierList.append(QString::fromStdString(qualifier));
}
- else if (index.column() == LogicalPortColumns::PAYLOADEXTENSION)
+
+ std::vector attributesList = portInterface_->getQualifierAttributes(index.row());
+ QMap attributes;
+
+ for (size_t i = 0; i + 1 < attributesList.size(); i += 2)
{
- return QString::fromStdString(portInterface_->getPayloadExtension(index.row()));
+ auto const& name = QString::fromStdString(attributesList.at(i));
+ auto const& value = QString::fromStdString(attributesList.at(i + 1));
+
+ attributes.insert(name, value);
}
+
+ return QVariant::fromValue(QualifierData{ qualifierList, attributes });
}
+
+ return expressionOrValueForIndex(index);
}
+
+ else if (role == Qt::ToolTipRole)
+ {
+ return valueForIndex(index);
+ }
+
else if (role == Qt::ForegroundRole)
{
- std::string portName = portInterface_->getIndexedItemName(index.row());
- General::InterfaceMode portMode = portInterface_->getMode(index.row());
- std::string portModeString = portInterface_->getModeString(index.row());
+ return blackForValidOrRedForInvalidIndex(index);
+ }
- if ((index.column() == LogicalPortColumns::NAME && QString::fromStdString(portName).isEmpty()) ||
- (index.column() == LogicalPortColumns::MODE &&
- (portMode == General::INTERFACE_MODE_COUNT ||
- portInterface_->portHasMultiplesOfMasterOrSlave(portName, portModeString))))
- {
- return KactusColors::ERROR;
- }
- else if (index.column() == LogicalPortColumns::SYSTEM_GROUP)
- {
- QString systemGroup = QString::fromStdString(portInterface_->getSystemGroup(index.row()));
- if (!busDefinition_ || (portMode == General::SYSTEM &&
- !BusDefinitionUtils::getSystemGroups(busDefinition_, libraryAccess_).contains(systemGroup)))
- {
- return KactusColors::ERROR;
- }
- }
- else if (isLocked(index))
- {
- return KactusColors::DISABLED_TEXT;
- }
+ else if (role == Qt::FontRole)
+ {
+ return italicForEvaluatedValue(index);
}
+
else if (role == Qt::DecorationRole && (index.column() == LogicalPortColumns::DIRECTION || index.column() == LogicalPortColumns::INITIATIVE))
{
std::string iconPath = portInterface_->getIconPathForSignal(index.row());
@@ -351,29 +290,6 @@ QVariant AbstractionPortsModel::data(QModelIndex const& index, int role) const
}
}
- else if (role == Qt::UserRole && index.column() == LogicalPortColumns::QUALIFIER)
- {
- QStringList qualifierList;
- for (auto const& qualifier : portInterface_->getQualifierStringList(index.row()))
- {
- qualifierList.append(QString::fromStdString(qualifier));
- }
-
- std::vector attributesList = portInterface_->getQualifierAttributes(index.row());
- QMap attributes;
-
- for (size_t i = 0; i + 1 < attributesList.size(); i += 2)
- {
- auto const& name = QString::fromStdString(attributesList.at(i));
- auto const& value = QString::fromStdString(attributesList.at(i + 1));
-
- attributes.insert(name, value);
- }
-
- return QVariant::fromValue(QualifierData{ qualifierList, attributes });
- }
-
-
return QVariant();
}
@@ -407,10 +323,22 @@ bool AbstractionPortsModel::setData(QModelIndex const& index, QVariant const& va
}
else if (index.column() == LogicalPortColumns::WIDTH)
{
+ if (!value.isValid())
+ {
+ removeReferencesFromSingleExpression(
+ QString::fromStdString(portInterface_->getWidthExpression(index.row())));
+ }
+
portInterface_->setWidth(index.row(), value.toString().toStdString());
}
else if (index.column() == LogicalPortColumns::DEFAULT_VALUE)
{
+ if (!value.isValid())
+ {
+ removeReferencesFromSingleExpression(
+ QString::fromStdString(portInterface_->getDefaultValueExpression(index.row())));
+ }
+
portInterface_->setDefaultValue(index.row(), value.toString().toStdString());
}
else if (index.column() == LogicalPortColumns::MODE)
@@ -427,6 +355,12 @@ bool AbstractionPortsModel::setData(QModelIndex const& index, QVariant const& va
}
else if (index.column() == LogicalPortColumns::BUSWIDTH)
{
+ if (!value.isValid())
+ {
+ removeReferencesFromSingleExpression(
+ QString::fromStdString(portInterface_->getBusWidthExpression(index.row())));
+ }
+
portInterface_->setBusWidth(index.row(), value.toString().toStdString());
}
else if (index.column() == LogicalPortColumns::SYSTEM_GROUP)
@@ -500,39 +434,30 @@ bool AbstractionPortsModel::setData(QModelIndex const& index, QVariant const& va
//-----------------------------------------------------------------------------
void AbstractionPortsModel::setQualifierData(QModelIndex const& index, QVariant const& value)
{
- if (portInterface_->getRevision() == Document::Revision::Std22)
- {
- QualifierData qualifierData = value.value();
- auto const& setQualifiers = qualifierData.activeQualifiers_;
- auto const& setAttributes = qualifierData.attributes_;
+ QualifierData qualifierData = value.value();
+ auto const& setQualifiers = qualifierData.activeQualifiers_;
+ auto const& setAttributes = qualifierData.attributes_;
- std::vector qualifierList;
- std::vector attributeList;
+ std::vector qualifierList;
+ std::vector attributeList;
- for (auto const& qualifier : setQualifiers)
- {
- qualifierList.push_back(qualifier.toStdString());
- }
+ for (auto const& qualifier : setQualifiers)
+ {
+ qualifierList.push_back(qualifier.toStdString());
+ }
+
+ portInterface_->setQualifierStringList(index.row(), qualifierList);
+ if (portInterface_->getRevision() == Document::Revision::Std22)
+ {
for (auto const& attributeName : setAttributes.keys())
{
attributeList.push_back(attributeName.toStdString());
attributeList.push_back(setAttributes[attributeName].toStdString());
}
- portInterface_->setQualifierStringList(index.row(), qualifierList);
portInterface_->setQualifierAttributes(index.row(), attributeList);
}
- else
- {
- std::vector qualifiersList;
- for (auto const& item : value.toStringList())
- {
- qualifiersList.push_back(item.toStdString());
- }
-
- portInterface_->setQualifierStringList(index.row(), qualifiersList);
- }
}
//-----------------------------------------------------------------------------
@@ -797,7 +722,7 @@ QStringList AbstractionPortsModel::getMissingSystemGroupsForSignal(int const& si
missingSystemGroups = BusDefinitionUtils::getSystemGroups(busDefinition_, libraryAccess_);
}
- for (auto currentSystem :
+ for (auto const& currentSystem :
portInterface_->getSystemGroupsForPort(portInterface_->getIndexedItemName(signalIndex)))
{
missingSystemGroups.removeAll(QString::fromStdString(currentSystem));
@@ -806,6 +731,216 @@ QStringList AbstractionPortsModel::getMissingSystemGroupsForSignal(int const& si
return missingSystemGroups;
}
+//-----------------------------------------------------------------------------
+// Function: AbstractionPortsModel::isValidExpressionColumn()
+//-----------------------------------------------------------------------------
+bool AbstractionPortsModel::isValidExpressionColumn(QModelIndex const& index) const
+{
+ auto col = index.column();
+ return col == LogicalPortColumns::BUSWIDTH || col == LogicalPortColumns::WIDTH ||
+ col == LogicalPortColumns::DEFAULT_VALUE;
+}
+
+//-----------------------------------------------------------------------------
+// Function: AbstractionPortsModel::expressionOrValueForIndex()
+//-----------------------------------------------------------------------------
+QVariant AbstractionPortsModel::expressionOrValueForIndex(QModelIndex const& index) const
+{
+ if (isValidExpressionColumn(index))
+ {
+ return expressionForIndex(index);
+ }
+ else
+ {
+ return valueForIndex(index);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Function: AbstractionPortsModel::expressionForIndex()
+//-----------------------------------------------------------------------------
+QVariant AbstractionPortsModel::expressionForIndex(QModelIndex const& index) const
+{
+ if (auto column = index.column(); column == LogicalPortColumns::BUSWIDTH)
+ {
+ return QString::fromStdString(portInterface_->getBusWidthExpression(index.row()));
+ }
+ else if (column == LogicalPortColumns::DEFAULT_VALUE)
+ {
+ return QString::fromStdString(portInterface_->getDefaultValueExpression(index.row()));
+ }
+ else if (column == LogicalPortColumns::WIDTH)
+ {
+ return QString::fromStdString(portInterface_->getWidthExpression(index.row()));
+ }
+
+ return QVariant();
+}
+
+//-----------------------------------------------------------------------------
+// Function: AbstractionPortsModel::validateIndex()
+//-----------------------------------------------------------------------------
+bool AbstractionPortsModel::validateIndex(QModelIndex const& index) const
+{
+ auto column = index.column();
+
+ auto portName = portInterface_->getIndexedItemName(index.row());
+
+ if (column == LogicalPortColumns::NAME)
+ {
+ return portInterface_->itemHasValidName(portName);
+ }
+ else if (column == LogicalPortColumns::BUSWIDTH)
+ {
+ return portInterface_->transactionalHasValidBusWidth(index.row());
+ }
+ else if (column == LogicalPortColumns::DEFAULT_VALUE)
+ {
+ return portInterface_->wireHasValidDefaultValue(index.row());
+ }
+ else if (column == LogicalPortColumns::WIDTH)
+ {
+ return portInterface_->wireHasValidWidth(index.row());
+ }
+
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+// Function: AbstractionPortsModel::getAllReferencesToIdInItemOnRow()
+//-----------------------------------------------------------------------------
+int AbstractionPortsModel::getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const
+{
+ return portInterface_->getAllReferencesToIdInRow(row, valueID.toStdString());
+}
+
+//-----------------------------------------------------------------------------
+// Function: AbstractionPortsModel::valueForIndex()
+//-----------------------------------------------------------------------------
+QVariant AbstractionPortsModel::valueForIndex(const QModelIndex& index) const
+{
+ if (index.column() == LogicalPortColumns::NAME)
+ {
+ QString logicalName = QString::fromStdString(portInterface_->getIndexedItemName(index.row()));
+ if (logicalName.isEmpty())
+ {
+ return "unnamed";
+ }
+ else
+ {
+ return logicalName;
+ }
+ }
+ else if (index.column() == LogicalPortColumns::QUALIFIER)
+ {
+ QStringList qualifierList;
+ for (auto const& qualifier : portInterface_->getQualifierStringList(index.row()))
+ {
+ qualifierList.append(QString::fromStdString(qualifier));
+ }
+
+ return qualifierList.join(", ");
+ }
+ else if (index.column() == LogicalPortColumns::MATCH)
+ {
+ return General::bool2Str(portInterface_->getMatch(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::WIDTH)
+ {
+ return QString::fromStdString(portInterface_->getWidthValue(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::DIRECTION)
+ {
+ return QString::fromStdString(portInterface_->getDirectionString(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::MODE)
+ {
+ return QString::fromStdString(portInterface_->getModeString(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::SYSTEM_GROUP)
+ {
+ return QString::fromStdString(portInterface_->getSystemGroup(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::PRESENCE)
+ {
+ return QString::fromStdString(portInterface_->getPresenceString(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::KIND)
+ {
+ return QString::fromStdString(portInterface_->getKind(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::INITIATIVE)
+ {
+ return QString::fromStdString(portInterface_->getInitiative(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::BUSWIDTH)
+ {
+ return QString::fromStdString(portInterface_->getBusWidthValue(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::DEFAULT_VALUE)
+ {
+ return QString::fromStdString(portInterface_->getDefaultValueValue(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::DRIVER)
+ {
+ return QString::fromStdString(portInterface_->getDriverString(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::DESCRIPTION)
+ {
+ std::string portName = portInterface_->getIndexedItemName(index.row());
+ return QString::fromStdString(portInterface_->getDescription(portName));
+ }
+ else if ((index.column() == LogicalPortColumns::PROTOCOLTYPE ||
+ index.column() == LogicalPortColumns::PAYLOADNAME ||
+ index.column() == LogicalPortColumns::PAYLOADTYPE ||
+ index.column() == LogicalPortColumns::PAYLOADEXTENSION) &&
+ portInterface_->hasProtocol(index.row()))
+ {
+ if (index.column() == LogicalPortColumns::PROTOCOLTYPE)
+ {
+ return QString::fromStdString(portInterface_->getProtocolType(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::PAYLOADNAME)
+ {
+ return QString::fromStdString(portInterface_->getPayloadName(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::PAYLOADTYPE)
+ {
+ return QString::fromStdString(portInterface_->getPayloadType(index.row()));
+ }
+ else if (index.column() == LogicalPortColumns::PAYLOADEXTENSION)
+ {
+ return QString::fromStdString(portInterface_->getPayloadExtension(index.row()));
+ }
+ }
+
+ return QVariant();
+}
+
+//-----------------------------------------------------------------------------
+// Function: AbstractionPortsModel::formattedExpressionForIndex()
+//-----------------------------------------------------------------------------
+QVariant AbstractionPortsModel::formattedExpressionForIndex(QModelIndex const& index) const
+{
+ int column = index.column();
+ int row = index.row();
+
+ if (column == LogicalPortColumns::WIDTH)
+ {
+ return QString::fromStdString(portInterface_->getWidthFormattedExpression(row));
+ }
+ else if (column == LogicalPortColumns::BUSWIDTH)
+ {
+ return QString::fromStdString(portInterface_->getBusWidthFormattedExpression(row));
+ }
+ else if (column == LogicalPortColumns::DEFAULT_VALUE)
+ {
+ return QString::fromStdString(portInterface_->getDefaultValueFormattedExpression(row));
+ }
+
+ return QVariant();
+}
+
//-----------------------------------------------------------------------------
// Function: AbstractionWirePortsModel::onRemoveItem()
//-----------------------------------------------------------------------------
@@ -913,7 +1048,7 @@ void AbstractionPortsModel::extendTransactionalMode(std::string const& port, Gen
portInterface_->setQualifierAttributes(index, extendInterface_->getQualifierAttributes(extendIndex));
portInterface_->setInitiative(index, extendInterface_->getInitiative(extendIndex));
portInterface_->setKind(index, extendInterface_->getKind(extendIndex));
- portInterface_->setBusWidth(index, extendInterface_->getBusWidthValue(extendIndex));
+ portInterface_->setBusWidth(index, extendInterface_->getBusWidthExpression(extendIndex));
portInterface_->setMatch(index, extendInterface_->getMatch(extendIndex));
portInterface_->setProtocolType(index, extendInterface_->getProtocolType(extendIndex));
diff --git a/editors/AbstractionDefinitionEditor/AbstractionPortsModel.h b/editors/AbstractionDefinitionEditor/AbstractionPortsModel.h
index 6df7d60c6..440a2011e 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionPortsModel.h
+++ b/editors/AbstractionDefinitionEditor/AbstractionPortsModel.h
@@ -12,6 +12,9 @@
#ifndef ABSTRACTIONPORTSMODEL_H
#define ABSTRACTIONPORTSMODEL_H
+#include
+#include
+
#include
#include
@@ -36,7 +39,7 @@ class WirePort;
//-----------------------------------------------------------------------------
//! Data model for the signals within abstraction definition.
//-----------------------------------------------------------------------------
-class AbstractionPortsModel : public QAbstractTableModel
+class AbstractionPortsModel : public ReferencingTableModel, public ParameterizableTable
{
Q_OBJECT
@@ -54,12 +57,16 @@ class AbstractionPortsModel : public QAbstractTableModel
/*!
* The constructor.
*
- * @param [in] libraryAccess Interface to the library.
- * @param [in] parent Pointer to the owner of this model.
+ * @param [in] parameterFinder The parameter finder to use.
+ * @param [in] expressionParser The expression parser to use.
+ * @param [in] libraryAccess Interface to the library.
+ * @param [in] portInterface The port abstraction interface to use.
+ * @param [in] extendInterface The port abstraction interface to use for extended abstractions.
+ * @param [in] parent Pointer to the owner of this model.
*/
- AbstractionPortsModel(LibraryInterface* libraryAccess, PortAbstractionInterface* portInterface,
- PortAbstractionInterface* extendInterface,
- QObject *parent);
+ AbstractionPortsModel(QSharedPointer parameterFinder,
+ QSharedPointer expressionParser, LibraryInterface* libraryAccess,
+ PortAbstractionInterface* portInterface, PortAbstractionInterface* extendInterface, QObject *parent);
/*!
* The destructor.
@@ -307,6 +314,67 @@ public slots:
QStringList getMissingSystemGroupsForSignal(int const& signalIndex) const;
+ /*!
+ * Check if the column index is valid for containing expressions.
+ *
+ * @param [in] index The index being evaluated.
+ *
+ * @return True, if column can have expressions, false otherwise.
+ */
+ bool isValidExpressionColumn(QModelIndex const& index) const final;
+
+ /*!
+ * Gets the expression for the given index or the plain value if expression is not available.
+ *
+ * @param [in] index The index whose expression to get.
+ *
+ * @return The expression for the index if available, otherwise the value for the given index.
+ */
+ QVariant expressionOrValueForIndex(QModelIndex const& index) const final;
+
+ /*!
+ * Get the unformatted expression for a selected index.
+ *
+ * @param [in] index Index to get the expression of.
+ *
+ * @return The unformatted expression.
+ */
+ QVariant expressionForIndex(QModelIndex const& index) const;
+
+ /*!
+ * Validates the data in an index.
+ *
+ * @param [in] index The index whose data to validate
+ *
+ * @return True, if the data in the index is valid, otherwise false.
+ */
+ bool validateIndex(QModelIndex const& index) const final;
+
+ /*!
+ * Gets the number of all the references made to a selected id on the selected row.
+ *
+ * @param [in] row The row of the selected item.
+ * @param [in] valueID The id of the referenced parameter.
+ *
+ * @return The amount of references made to the selected id on the selected row.
+ */
+ int getAllReferencesToIdInItemOnRow(const int& row, QString const& valueID) const final;
+
+ /*!
+ * Get the value for the corresponding index.
+ *
+ * @param [in] index The index whose value is being searched for.
+ */
+ QVariant valueForIndex(const QModelIndex& index) const;
+
+ /*!
+ * Get the formatted value of an expression in the selected index.
+ *
+ * @param [in] index The selected index.
+ *
+ * @return The formatted value of an expression in the selected index.
+ */
+ QVariant formattedExpressionForIndex(QModelIndex const& index) const;
//-----------------------------------------------------------------------------
// Data.
diff --git a/editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.cpp b/editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.cpp
index f6d9ce5ce..2b066b735 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.cpp
+++ b/editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.cpp
@@ -22,13 +22,22 @@
//-----------------------------------------------------------------------------
// Function: AbstractionTransactionalPortsDelegate::AbstractionTransactionalPortsDelegate()
//-----------------------------------------------------------------------------
-AbstractionTransactionalPortsDelegate::AbstractionTransactionalPortsDelegate(LibraryInterface* libraryAccess,
- Document::Revision stdRevision, QObject *parent):
-AbstractionPortsDelegate(libraryAccess, stdRevision, parent)
+AbstractionTransactionalPortsDelegate::AbstractionTransactionalPortsDelegate(QAbstractItemModel* parametersModel,
+ QSharedPointer parameterFinder, LibraryInterface* libraryAccess,
+ Document::Revision stdRevision, QObject* parent) :
+AbstractionPortsDelegate(parametersModel, parameterFinder, libraryAccess, stdRevision, parent)
{
}
+//-----------------------------------------------------------------------------
+// Function: AbstractionTransactionalPortsDelegate::columnAcceptsExpression()
+//-----------------------------------------------------------------------------
+bool AbstractionTransactionalPortsDelegate::columnAcceptsExpression(int column) const
+{
+ return column == LogicalPortColumns::BUSWIDTH;
+}
+
//-----------------------------------------------------------------------------
// Function: AbstractionTransactionalPortsDelegate::createEditor()
//-----------------------------------------------------------------------------
diff --git a/editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.h b/editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.h
index 598f51072..c7e6877e5 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.h
+++ b/editors/AbstractionDefinitionEditor/AbstractionTransactionalPortsDelegate.h
@@ -27,12 +27,15 @@ class AbstractionTransactionalPortsDelegate : public AbstractionPortsDelegate
/*!
* The constructor.
*
+ * @param [in] parametersModel The parameter completer model to use.
+ * @param [in] parameterFinder The parameter finder to use.
* @param [in] libraryAccess Interface to the library.
* @param [in] stdRevision The standard revision used by the abstraction definition.
* @param [in] parent The owner of this instance
*/
- AbstractionTransactionalPortsDelegate(LibraryInterface* libraryAccess, Document::Revision stdRevision,
- QObject *parent);
+ AbstractionTransactionalPortsDelegate(QAbstractItemModel* parametersModel,
+ QSharedPointer parameterFinder, LibraryInterface* libraryAccess,
+ Document::Revision stdRevision, QObject *parent);
/*!
* The destructor.
@@ -54,6 +57,18 @@ class AbstractionTransactionalPortsDelegate : public AbstractionPortsDelegate
//! No copying. No assignment.
AbstractionTransactionalPortsDelegate(const AbstractionTransactionalPortsDelegate& other) = delete;
AbstractionTransactionalPortsDelegate& operator=(const AbstractionTransactionalPortsDelegate& other) = delete;
+
+private:
+
+ /*!
+ * Checks if the given column supports expressions in the editor.
+ *
+ * @param [in] column The column to check.
+ *
+ * @return True, if the cells in the column allow expressions, otherwise false.
+ */
+ bool columnAcceptsExpression(int column) const final;
+
};
#endif // ABSTRACTIONTRANSACTIONALPORTSDELEGATE_H
diff --git a/editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.cpp b/editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.cpp
index 273167e06..68a483bd5 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.cpp
+++ b/editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.cpp
@@ -21,9 +21,10 @@
//-----------------------------------------------------------------------------
// Function: AbstractionWirePortsDelegate::AbstractionWirePortsDelegate()
//-----------------------------------------------------------------------------
-AbstractionWirePortsDelegate::AbstractionWirePortsDelegate(LibraryInterface* libraryAccess,
+AbstractionWirePortsDelegate::AbstractionWirePortsDelegate(QAbstractItemModel* parametersModel,
+ QSharedPointer parameterFinder, LibraryInterface* libraryAccess,
Document::Revision stdRevision, QObject *parent):
-AbstractionPortsDelegate(libraryAccess, stdRevision, parent)
+AbstractionPortsDelegate(parametersModel, parameterFinder, libraryAccess, stdRevision, parent)
{
}
@@ -73,20 +74,16 @@ QWidget* AbstractionWirePortsDelegate::createEditor(QWidget* parent, QStyleOptio
QStringList AbstractionWirePortsDelegate::getQualifierList() const
{
QStringList qualifierList = AbstractionPortsDelegate::getQualifierList();
- qualifierList.append(getExclusiveItems());
+
+ // In 1685-2014 clock and reset are only for wires
+ if (stdRevision_ != Document::Revision::Std22)
+ {
+ qualifierList << QStringLiteral("clock") << QStringLiteral("reset");
+ }
return qualifierList;
}
-//-----------------------------------------------------------------------------
-// Function: AbstractionWirePortsDelegate::editorIsLineEditor()
-//-----------------------------------------------------------------------------
-bool AbstractionWirePortsDelegate::editorIsLineEditor(int indexColumn) const
-{
- return AbstractionPortsDelegate::editorIsLineEditor(indexColumn) ||
- indexColumn == LogicalPortColumns::DEFAULT_VALUE;
-}
-
//-----------------------------------------------------------------------------
// Function: AbstractionWirePortsDelegate::editorIsComboBox()
//-----------------------------------------------------------------------------
@@ -97,15 +94,9 @@ bool AbstractionWirePortsDelegate::editorIsComboBox(int indexColumn) const
}
//-----------------------------------------------------------------------------
-// Function: AbstractionWirePortsDelegate::getExclusiveItems()
+// Function: AbstractionWirePortsDelegate::columnAcceptsExpression()
//-----------------------------------------------------------------------------
-QStringList AbstractionWirePortsDelegate::getExclusiveItems() const
+bool AbstractionWirePortsDelegate::columnAcceptsExpression(int column) const
{
- QStringList list;
- if (stdRevision_ != Document::Revision::Std22)
- {
- list << QStringLiteral("clock") << QStringLiteral("reset");
- }
-
- return list;
+ return column == LogicalPortColumns::DEFAULT_VALUE || column == LogicalPortColumns::WIDTH;
}
diff --git a/editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.h b/editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.h
index 920165125..e5cb32c8f 100644
--- a/editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.h
+++ b/editors/AbstractionDefinitionEditor/AbstractionWirePortsDelegate.h
@@ -25,12 +25,15 @@ class AbstractionWirePortsDelegate : public AbstractionPortsDelegate
/*!
* The constructor.
- *
+ *
+ * @param [in] parametersModel The parameter completer model to use.
+ * @param [in] parameterFinder The parameter finder to use.
* @param [in] libraryAccess Interface to the library.
* @param [in] stdRevision The standard revision used by the abstraction definition.
* @param [in] parent The owner of this instance
*/
- AbstractionWirePortsDelegate(LibraryInterface* libraryAccess, Document::Revision stdRevision, QObject *parent);
+ AbstractionWirePortsDelegate(QAbstractItemModel* parametersModel, QSharedPointer parameterFinder,
+ LibraryInterface* libraryAccess, Document::Revision stdRevision, QObject *parent);
/*!
* The destructor.
@@ -60,16 +63,7 @@ class AbstractionWirePortsDelegate : public AbstractionPortsDelegate
*
* @return The list of available qualifier values.
*/
- virtual QStringList getQualifierList() const;
-
- /*!
- * Check if the editor used in the selected index column is a line editor.
- *
- * @param [in] indexColumn The selected index column.
- *
- * @return True, if the editor used in the selected column is a line editor, false otherwise.
- */
- virtual bool editorIsLineEditor(int indexColumn) const;
+ QStringList getQualifierList() const override;
/*!
* Check if the editor used in the selected index column is a combo box editor.
@@ -81,13 +75,16 @@ class AbstractionWirePortsDelegate : public AbstractionPortsDelegate
virtual bool editorIsComboBox(int indexColumn) const;
private:
-
+
/*!
- * Get the list of exclusive enumerations.
+ * Checks if the given column supports expressions in the editor.
*
- * @return List of exclusive enumerations.
+ * @param [in] column The column to check.
+ *
+ * @return True, if the cells in the column allow expressions, otherwise false.
*/
- virtual QStringList getExclusiveItems() const override final;
+ bool columnAcceptsExpression(int column) const final;
+
};
#endif // ABSTRACTIONWIREPORTSDELEGATE_H
diff --git a/editors/AbstractionDefinitionEditor/QualifierEditor.cpp b/editors/AbstractionDefinitionEditor/QualifierEditor.cpp
index ceeea1b18..e9edd7483 100644
--- a/editors/AbstractionDefinitionEditor/QualifierEditor.cpp
+++ b/editors/AbstractionDefinitionEditor/QualifierEditor.cpp
@@ -21,14 +21,16 @@
//-----------------------------------------------------------------------------
// Function: QualifierEditor::QualifierEditor()
//-----------------------------------------------------------------------------
-QualifierEditor::QualifierEditor(QWidget* parent):
+QualifierEditor::QualifierEditor(Document::Revision stdRevision, QWidget *parent) :
QFrame(parent),
+ qualifierAndAttributelayout_(new QGridLayout()),
powerDomainLineEdit_(new QLineEdit()),
userDefinedLineEdit_(new QLineEdit()),
resetLevelSelector_(new QComboBox()),
clockEnableLevelSelector_(new QComboBox()),
powerEnableLevelSelector_(new QComboBox()),
- flowTypeSelector_(new QComboBox())
+ flowTypeSelector_(new QComboBox()),
+ stdRevision_(stdRevision)
{
setFrameStyle(QFrame::StyledPanel);
setFocusPolicy(Qt::StrongFocus);
@@ -56,29 +58,47 @@ QualifierEditor::QualifierEditor(QWidget* parent):
flowTypeSelector_->lineEdit()->setPlaceholderText(QStringLiteral("Flow type"));
userDefinedLineEdit_->setPlaceholderText(QStringLiteral("User defined attribute"));
- populateCheckBoxes();
setupLayout();
}
//-----------------------------------------------------------------------------
// Function: QualifierEditor::setupEditor()
//-----------------------------------------------------------------------------
-void QualifierEditor::setupEditor(QStringList const& allQualifiers, QStringList const& activeQualifiers,
- QMap const& attributes)
-{
- for (auto const& qualifier : allQualifiers)
+void QualifierEditor::setupEditor(QStringList const& qualifierOptions)
+{
+ for (auto const& qualifier : qualifierOptions)
{
- bool selected = activeQualifiers.contains(qualifier);
+ auto qualifierAsType = Qualifier::stringToType(qualifier);
+ auto attributeEditor = getAttributeEditor(qualifierAsType);
+
+ QCheckBox* qualifierBox = new QCheckBox(qualifier, this);
+ qualifierBoxes_.insert(qualifierAsType, qualifierBox);
+
+ connect(qualifierBox, SIGNAL(clicked(bool)), this, SLOT(onItemClicked(bool)), Qt::UniqueConnection);
+
+ qualifierAndAttributelayout_->addWidget(qualifierBox, qualifierAndAttributelayout_->rowCount(), 0);
- for (auto box : qualifierBoxes_)
+ if (attributeEditor)
{
- if (box->text() == qualifier)
- {
- box->setChecked(selected);
- }
+ qualifierAndAttributelayout_->addWidget(attributeEditor, qualifierAndAttributelayout_->rowCount() - 1, 1);
}
+ }
+}
- setQualifierAttributesVisible(Qualifier::stringToType(qualifier), selected);
+//-----------------------------------------------------------------------------
+// Function: QualifierEditor::setupEditorData()
+//-----------------------------------------------------------------------------
+void QualifierEditor::setupEditorData(QStringList const& activeQualifiers, QMap const& attributes)
+{
+ for (auto const& qualifier : activeQualifiers)
+ {
+ auto qualifierAsType = Qualifier::stringToType(qualifier);
+
+ if (qualifierBoxes_.contains(qualifierAsType))
+ {
+ qualifierBoxes_[qualifierAsType]->setChecked(true);
+ setQualifierAttributesVisible(qualifierAsType, true);
+ }
}
for (auto const& attributeName : attributes.keys())
@@ -87,6 +107,18 @@ void QualifierEditor::setupEditor(QStringList const& allQualifiers, QStringList
}
}
+//-----------------------------------------------------------------------------
+// Function: QualifierEditor::hideAllAttributes()
+//-----------------------------------------------------------------------------
+void QualifierEditor::hideAllAttributes()
+{
+ setQualifierAttributesVisible(Qualifier::Type::ClockEnable, false);
+ setQualifierAttributesVisible(Qualifier::Type::FlowControl, false);
+ setQualifierAttributesVisible(Qualifier::Type::PowerEnable, false);
+ setQualifierAttributesVisible(Qualifier::Type::Reset, false);
+ setQualifierAttributesVisible(Qualifier::Type::User, false);
+}
+
//-----------------------------------------------------------------------------
// Function: QualifierEditor::getSelectedItems()
//-----------------------------------------------------------------------------
@@ -159,39 +191,10 @@ void QualifierEditor::onItemClicked(bool isChecked)
return;
}
- auto qualifier = Qualifier::stringToType(sender->text());
- setQualifierAttributesVisible(qualifier, isChecked);
-}
-
-//-----------------------------------------------------------------------------
-// Function: QualifierEditor::populateCheckBoxes()
-//-----------------------------------------------------------------------------
-void QualifierEditor::populateCheckBoxes()
-{
- static constexpr std::array qualifierOrder =
- {
- Qualifier::Type::Address,
- Qualifier::Type::Data,
- Qualifier::Type::Interrupt,
- Qualifier::Type::Opcode,
- Qualifier::Type::Clock,
- Qualifier::Type::ClockEnable,
- Qualifier::Type::Reset,
- Qualifier::Type::PowerEnable,
- Qualifier::Type::Protection,
- Qualifier::Type::FlowControl,
- Qualifier::Type::Request,
- Qualifier::Type::Response,
- Qualifier::Type::Valid,
- Qualifier::Type::User
- };
-
- for (auto const& qualifier : qualifierOrder)
+ if (stdRevision_ == Document::Revision::Std22)
{
- QCheckBox* qualifierBox = new QCheckBox(Qualifier::typeToString(qualifier), this);
- qualifierBoxes_.append(qualifierBox);
-
- connect(qualifierBox, SIGNAL(clicked(bool)), this, SLOT(onItemClicked(bool)), Qt::UniqueConnection);
+ auto qualifier = Qualifier::stringToType(sender->text());
+ setQualifierAttributesVisible(qualifier, isChecked);
}
}
@@ -204,25 +207,12 @@ void QualifierEditor::setupLayout()
QWidget* qualifiersAndAttributes = new QWidget();
- QGridLayout* qualifierAndAttributelayout = new QGridLayout();
-
QScrollArea* scrollingWidget = new QScrollArea();
scrollingWidget->setWidgetResizable(true);
scrollingWidget->setWidget(qualifiersAndAttributes);
scrollingWidget->setFrameShape(QFrame::NoFrame);
scrollingWidget->setContentsMargins(0, 0, 0, 0);
- for (int i = 0; i < qualifierBoxes_.size(); ++i)
- {
- qualifierAndAttributelayout->addWidget(qualifierBoxes_.at(i), i, 0);
- }
-
- qualifierAndAttributelayout->addWidget(resetLevelSelector_, 6, 1);
- qualifierAndAttributelayout->addWidget(clockEnableLevelSelector_, 5, 1);
- qualifierAndAttributelayout->addWidget(powerEnableLevelSelector_, 7, 1);
- qualifierAndAttributelayout->addWidget(flowTypeSelector_, 9, 1);
- qualifierAndAttributelayout->addWidget(userDefinedLineEdit_, 13, 1);
-
QPushButton* okButton = new QPushButton();
okButton->setIcon(QIcon(":/icons/common/graphics/checkMark.png"));
okButton->setToolTip("Accept");
@@ -239,7 +229,7 @@ void QualifierEditor::setupLayout()
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);
- qualifiersAndAttributes->setLayout(qualifierAndAttributelayout);
+ qualifiersAndAttributes->setLayout(qualifierAndAttributelayout_);
qualifiersAndAttributes->setContentsMargins(0, 0, 0, 0);
setMinimumHeight(sizeHint().height());
editorLayout->addWidget(scrollingWidget);
@@ -297,6 +287,37 @@ QComboBox* QualifierEditor::getAttributeEditor(Qualifier::Attribute attribute)
}
}
+//-----------------------------------------------------------------------------
+// Function: QualifierEditor::getAttributeEditor()
+//-----------------------------------------------------------------------------
+QWidget* QualifierEditor::getAttributeEditor(Qualifier::Type qualifierType)
+{
+ if (qualifierType == Qualifier::Type::Reset)
+ {
+ return resetLevelSelector_;
+ }
+ else if (qualifierType == Qualifier::Type::ClockEnable)
+ {
+ return clockEnableLevelSelector_;
+ }
+ else if (qualifierType == Qualifier::Type::PowerEnable)
+ {
+ return powerEnableLevelSelector_;
+ }
+ else if (qualifierType == Qualifier::Type::FlowControl)
+ {
+ return flowTypeSelector_;
+ }
+ else if (qualifierType == Qualifier::Type::User)
+ {
+ return userDefinedLineEdit_;
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
//-----------------------------------------------------------------------------
// Function: QualifierEditor::setQualifierAttributesVisible()
//-----------------------------------------------------------------------------
diff --git a/editors/AbstractionDefinitionEditor/QualifierEditor.h b/editors/AbstractionDefinitionEditor/QualifierEditor.h
index ef29a6e09..33400ed9e 100644
--- a/editors/AbstractionDefinitionEditor/QualifierEditor.h
+++ b/editors/AbstractionDefinitionEditor/QualifierEditor.h
@@ -15,6 +15,7 @@
#include "QualifierData.h"
#include
+#include
#include
#include
@@ -22,6 +23,8 @@
#include
#include
+class QGridLayout;
+
//-----------------------------------------------------------------------------
//! Editor for qualifiers in 2022 standard Abstraction Definition.
//-----------------------------------------------------------------------------
@@ -34,10 +37,10 @@ class QualifierEditor : public QFrame
/*!
* The constructor.
*
- * @param [in] libraryAccess Interface to the library.
+ * @param [in] stdRevision The IP-XACT standard revision in use.
* @param [in] parent The owner of this instance
*/
- QualifierEditor(QWidget *parent);
+ QualifierEditor(Document::Revision stdRevision, QWidget *parent);
virtual ~QualifierEditor() = default;
@@ -48,12 +51,23 @@ class QualifierEditor : public QFrame
/*!
* Setup the qualifier editor.
*
- * @param [in] allQualifiers List of all possible qualifiers.
- * @param [in] activeQualifiers List of selected qualifiers.
- * @param [in] attributes Map of the qualifier's attributes.
+ * @param [in] qualifierOptions List of all possible qualifiers.
*/
- void setupEditor(QStringList const& allQualifiers, QStringList const& activeQualifiers, QMap const& attributes);
+ void setupEditor(QStringList const& qualifierOptions);
+ /*!
+ * Set the editor data.
+ *
+ * @param [in] activeQualifiers The qualifiers that should be set checked.
+ * @param [in] attributes The qualifier attributes to set.
+ */
+ void setupEditorData(QStringList const& activeQualifiers, QMap const& attributes);
+
+ /*!
+ * Hide all attribute editors from the editor.
+ */
+ void hideAllAttributes();
+
/*!
* Get the qualifier data from the editor.
*
@@ -98,11 +112,6 @@ private slots:
*/
QMap getAttributes() const;
- /*!
- * Populate the editor with qualifier checkboxes.
- */
- void populateCheckBoxes();
-
/*!
* Setup the editor layout.
*/
@@ -125,6 +134,15 @@ private slots:
*/
QComboBox* getAttributeEditor(Qualifier::Attribute attribute);
+ /*!
+ * Get the attribute editor for a given qualifier type.
+ *
+ * @param [in] qualifierType The qualfier type whose attribute editor to get.
+ *
+ * @return The attribute editor, or nullptr if not found.
+ */
+ QWidget* getAttributeEditor(Qualifier::Type qualifierType);
+
/*!
* Set the visibility for the attributes of a qualifier, based on if qualifier is set.
*
@@ -146,6 +164,9 @@ private slots:
*/
QList getQualifierTypeAttributes(Qualifier::Type qualifier);
+ //! The qualifiers and attributes layout.
+ QGridLayout* qualifierAndAttributelayout_;
+
//! The editor for the power domain reference. Not used in absDef.
QLineEdit* powerDomainLineEdit_;
@@ -160,8 +181,8 @@ private slots:
//! Editable combobox for flow control flow type.
QComboBox* flowTypeSelector_;
- //! List of the qualifier checkboxes.
- QList qualifierBoxes_;
+ //! Map of qualifier checkboxes and their associated type.
+ QHash qualifierBoxes_;
//! List of pre-set flow types. If flow type is not in this list,
// Then it will be set as user.
@@ -170,6 +191,9 @@ private slots:
QStringLiteral("ready"),
QStringLiteral("busy")
};
+
+ //! The IP-XACT standard revision in use.
+ Document::Revision stdRevision_;
};
#endif // QUALIFIEREDITOR_H
diff --git a/editors/AbstractionDefinitionEditor/absdefgroup.cpp b/editors/AbstractionDefinitionEditor/absdefgroup.cpp
index af7433b37..21a489e3a 100644
--- a/editors/AbstractionDefinitionEditor/absdefgroup.cpp
+++ b/editors/AbstractionDefinitionEditor/absdefgroup.cpp
@@ -19,6 +19,7 @@
#include
#include
+#include
#include
#include
@@ -26,6 +27,7 @@
#include
#include
+#include
#include "AbstractionDefinitionPortsSortFilter.h"
#include "AbstractionPortsModel.h"
@@ -41,9 +43,9 @@
// Function: AbsDefGroup::AbsDefGroup()
//-----------------------------------------------------------------------------
AbsDefGroup::AbsDefGroup(Document::Revision revision, QSharedPointer absDef,
- QSharedPointer expressionFormatter, QSharedPointer parameterFinder,
- LibraryInterface* libraryHandler, PortAbstractionInterface* portInterface,
- PortAbstractionInterface* extendInterface, QWidget* parent) :
+ QSharedPointer expressionFormatter, QSharedPointer expressionParser,
+ QSharedPointer parameterFinder, LibraryInterface* libraryHandler,
+ PortAbstractionInterface* portInterface, PortAbstractionInterface* extendInterface, QWidget* parent) :
QWidget(parent),
documentNameGroupEditor_(new DocumentNameGroupEditor(this)),
extendEditor_(new VLNVEditor(VLNV::ABSTRACTIONDEFINITION, libraryHandler, this, this)),
@@ -51,9 +53,15 @@ busDisplay_(new VLNVDisplayer(this, VLNV())),
portTabs_(this),
portInterface_(portInterface),
extendInterface_(extendInterface),
-portModel_(new AbstractionPortsModel(libraryHandler, portInterface, extendInterface, this)),
-wirePortsEditor_(new AbstractionPortsEditor(libraryHandler, portInterface, revision, portModel_, LogicalPortColumns::AbstractionType::WIRE, &portTabs_)),
-transactionalPortsEditor_(new AbstractionPortsEditor(libraryHandler, portInterface, revision, portModel_, LogicalPortColumns::AbstractionType::TRANSACTIONAL, &portTabs_)),
+parameterEditor_(new ParameterGroupBox(absDef->getParameters(), absDef->getChoices(), parameterFinder,
+ expressionFormatter, absDef->getRevision(), this)),
+parameterCompleter_(new ComponentParameterModel(parameterFinder, this)),
+portModel_(new AbstractionPortsModel(parameterFinder, expressionParser, libraryHandler, portInterface,
+ extendInterface, this)),
+wirePortsEditor_(new AbstractionPortsEditor(parameterCompleter_, parameterFinder, libraryHandler,
+ portInterface, revision, portModel_, LogicalPortColumns::AbstractionType::WIRE, &portTabs_)),
+transactionalPortsEditor_(new AbstractionPortsEditor(parameterCompleter_, parameterFinder, libraryHandler,
+ portInterface, revision, portModel_, LogicalPortColumns::AbstractionType::TRANSACTIONAL, &portTabs_)),
abstraction_(absDef),
libraryHandler_(libraryHandler)
{
@@ -69,9 +77,6 @@ libraryHandler_(libraryHandler)
portTabs_.addTab(wirePortsEditor_, QStringLiteral("Wire ports"));
portTabs_.addTab(transactionalPortsEditor_, QStringLiteral("Transactional ports"));
- parameterEditor_ = new ParameterGroupBox(absDef->getParameters(), absDef->getChoices(), parameterFinder, expressionFormatter,
- absDef->getRevision(), this);
-
connect(parameterEditor_, SIGNAL(increaseReferences(QString)),
this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);
connect(parameterEditor_, SIGNAL(decreaseReferences(QString)),
@@ -92,6 +97,10 @@ libraryHandler_(libraryHandler)
this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);
connect(wirePortsEditor_, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)),
this, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)), Qt::UniqueConnection);
+ connect(wirePortsEditor_, SIGNAL(increaseReferences(QString)),
+ this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);
+ connect(wirePortsEditor_, SIGNAL(decreaseReferences(QString)),
+ this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);
connect(transactionalPortsEditor_, SIGNAL(contentChanged()),
this, SIGNAL(contentChanged()), Qt::UniqueConnection);
@@ -101,6 +110,10 @@ libraryHandler_(libraryHandler)
this, SIGNAL(errorMessage(const QString&)), Qt::UniqueConnection);
connect(transactionalPortsEditor_, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)),
this, SIGNAL(portRemoved(const QString&, const General::InterfaceMode)), Qt::UniqueConnection);
+ connect(transactionalPortsEditor_, SIGNAL(increaseReferences(QString)),
+ this, SIGNAL(increaseReferences(QString)), Qt::UniqueConnection);
+ connect(transactionalPortsEditor_, SIGNAL(decreaseReferences(QString)),
+ this, SIGNAL(decreaseReferences(QString)), Qt::UniqueConnection);
connect(documentNameGroupEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);
diff --git a/editors/AbstractionDefinitionEditor/absdefgroup.h b/editors/AbstractionDefinitionEditor/absdefgroup.h
index 8322dd5f7..07c990b0b 100644
--- a/editors/AbstractionDefinitionEditor/absdefgroup.h
+++ b/editors/AbstractionDefinitionEditor/absdefgroup.h
@@ -32,8 +32,10 @@ class PortAbstractionInterface;
class DocumentNameGroupEditor;
class ParameterGroupBox;
class ExpressionFormatter;
+class ExpressionParser;
class ParameterFinder;
class AbstractParameterInterface;
+class ComponentParameterModel;
//-----------------------------------------------------------------------------
//! Editor for the logical ports of an abstraction definition.
@@ -50,15 +52,17 @@ class AbsDefGroup : public QWidget
* @param [in] revision Currently active IP-XACT revision.
* @param [in] absDef The abstraction definition.
* @param [in] expressionFormatter The expression formatter to use.
+ * @param [in] expressionParser The expression parser to use.
* @param [in] parameterFinder The parameter finder to use.
* @param [in] libraryHandler Allows access to the library.
* @param [in] portInterface Interface for accssing port abstractions.
+ * @param [in] extendInterface Interface for accssing extend port abstractions.
* @param [in] parent The owner of the editor.
*/
AbsDefGroup(Document::Revision revision, QSharedPointer absDef,
- QSharedPointer expressionFormatter, QSharedPointer parameterFinder,
- LibraryInterface* libraryHandler, PortAbstractionInterface* portInterface,
- PortAbstractionInterface* extendInterface, QWidget* parent);
+ QSharedPointer expressionFormatter, QSharedPointer expressionParser,
+ QSharedPointer parameterFinder, LibraryInterface* libraryHandler,
+ PortAbstractionInterface* portInterface, PortAbstractionInterface* extendInterface, QWidget* parent);
/*!
* The destructor.
@@ -205,9 +209,15 @@ private slots:
//! Interface for accessing extened port abstractions.
PortAbstractionInterface* extendInterface_;
+ //! The abstraction definition parameters editor.
+ ParameterGroupBox* parameterEditor_;
+
+ //! The parameter completer model to use.
+ ComponentParameterModel* parameterCompleter_;
+
//! The abstraction definition ports model.
AbstractionPortsModel* portModel_;
-
+
//! Editor for wire ports.
AbstractionPortsEditor* wirePortsEditor_;
@@ -219,9 +229,6 @@ private slots:
//! The library interface.
LibraryInterface* libraryHandler_;
-
- //! The abstraction definition parameters editor.
- ParameterGroupBox* parameterEditor_;
};
#endif // ABSDEFGROUP_H
diff --git a/editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.cpp b/editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.cpp
index 111de85e4..3d9377794 100644
--- a/editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.cpp
+++ b/editors/ComponentEditor/busInterfaces/portmaps/PortMapAutoConnector.cpp
@@ -154,7 +154,7 @@ QMultiMap PortMapAutoConnector::getWeightedPhysicalPorts(std::s
bool isValidWidth = false;
QString logicalWidth =
- QString::fromStdString(logicalInterface->getWidth(logicalPort, busMode, systemGroup));
+ QString::fromStdString(logicalInterface->getWidthValue(logicalPort, busMode, systemGroup));
int logicalWidthInt = logicalWidth.toInt(&isValidWidth);
diff --git a/editors/ComponentEditor/ports/portseditor.cpp b/editors/ComponentEditor/ports/portseditor.cpp
index fff5e429e..9b4440963 100644
--- a/editors/ComponentEditor/ports/portseditor.cpp
+++ b/editors/ComponentEditor/ports/portseditor.cpp
@@ -64,7 +64,7 @@ ItemEditor(component, handler, parent),
expressions,
portValidator,
portsInterface_,
- QSharedPointer(new PortAbstractionInterface()),
+ QSharedPointer(new PortAbstractionInterface(expressions.parser, expressions.formatter)),
busInterface,
QString());
diff --git a/editors/ComponentEditor/ports/portsmodel.cpp b/editors/ComponentEditor/ports/portsmodel.cpp
index 5e088a6f9..fbe613479 100644
--- a/editors/ComponentEditor/ports/portsmodel.cpp
+++ b/editors/ComponentEditor/ports/portsmodel.cpp
@@ -773,7 +773,7 @@ void PortsModel::onCreatePortsFromAbstraction(QSharedPointergetWidth(signalIndex)).toULongLong(&signalIntegerOk);
+ QString::fromStdString(signalInterface_->getWidthValue(signalIndex)).toULongLong(&signalIntegerOk);
if (signalIntegerOk == true && signalWidth > 0)
{
leftBound = signalWidth - 1;
@@ -782,7 +782,7 @@ void PortsModel::onCreatePortsFromAbstraction(QSharedPointersetLeftBound(portName, QString::number(leftBound).toStdString());
portsInterface_->setRightBound(portName, "0");
- portsInterface_->setDefaultValue(portName, signalInterface_->getDefaultValue(signalIndex));
+ portsInterface_->setDefaultValue(portName, signalInterface_->getDefaultValueExpression(signalIndex));
}
else if (signalInterface_->portIsTransactional(portName))
{
@@ -794,7 +794,7 @@ void PortsModel::onCreatePortsFromAbstraction(QSharedPointersetInitiative(portName, getInitiativeFromSignal(busInterfaceMode,
QString::fromStdString(signalInterface_->getInitiative(signalIndex))).toStdString());
portsInterface_->setKind(portName, signalInterface_->getKind(signalIndex));
- portsInterface_->setBusWidth(portName, signalInterface_->getBusWidthValue(signalIndex));
+ portsInterface_->setBusWidth(portName, signalInterface_->getBusWidthExpression(signalIndex));
}
portsInterface_->setDescription(portName, signalInterface_->getDescription(portName));
diff --git a/editors/ComponentEditor/treeStructure/TransactionalPortsItem.cpp b/editors/ComponentEditor/treeStructure/TransactionalPortsItem.cpp
index 9774dd32d..52e250b94 100644
--- a/editors/ComponentEditor/treeStructure/TransactionalPortsItem.cpp
+++ b/editors/ComponentEditor/treeStructure/TransactionalPortsItem.cpp
@@ -80,7 +80,7 @@ ItemEditor* TransactionalPortsItem::editor()
{
if (!editor_)
{
- QSharedPointer signalInterface(new PortAbstractionInterface());
+ QSharedPointer signalInterface(new PortAbstractionInterface(expressions_.parser, expressions_.formatter));
const QString defaultPath = QString("%1/transactionalList.csv").arg(libHandler_->getDirectoryPath(component_->getVlnv()));
diff --git a/editors/ComponentEditor/treeStructure/WirePortsItem.cpp b/editors/ComponentEditor/treeStructure/WirePortsItem.cpp
index a21761f0e..16277b9aa 100644
--- a/editors/ComponentEditor/treeStructure/WirePortsItem.cpp
+++ b/editors/ComponentEditor/treeStructure/WirePortsItem.cpp
@@ -79,7 +79,7 @@ ItemEditor* WirePortsItem::editor()
{
if (!editor_)
{
- QSharedPointer signalInterface(new PortAbstractionInterface());
+ QSharedPointer signalInterface(new PortAbstractionInterface(expressions_.parser, expressions_.formatter));
const QString defaultPath = QString("%1/wireList.csv").arg(libHandler_->getDirectoryPath(component_->getVlnv()));
diff --git a/version.h b/version.h
index 86d227b50..ce8c20e18 100644
--- a/version.h
+++ b/version.h
@@ -10,20 +10,20 @@
#ifndef VERSIONNO__H
#define VERSIONNO__H
-#define VERSION_FULL 3.13.593.0
+#define VERSION_FULL 3.13.640.0
#define VERSION_BASEYEAR 0
-#define VERSION_DATE "2024-09-04"
-#define VERSION_TIME "13:31:31"
+#define VERSION_DATE "2024-09-17"
+#define VERSION_TIME "16:22:30"
#define VERSION_MAJOR 3
#define VERSION_MINOR 13
-#define VERSION_BUILDNO 593
+#define VERSION_BUILDNO 640
#define VERSION_EXTEND 0
-#define VERSION_FILE 3,13,593,0
-#define VERSION_PRODUCT 3,13,593,0
-#define VERSION_FILESTR "3,13,593,0"
-#define VERSION_PRODUCTSTR "3,13,593,0"
+#define VERSION_FILE 3,13,640,0
+#define VERSION_PRODUCT 3,13,640,0
+#define VERSION_FILESTR "3,13,640,0"
+#define VERSION_PRODUCTSTR "3,13,640,0"
#endif