Skip to content

Commit

Permalink
Release v4.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Nov 8, 2023
2 parents 3b4f551 + 80b8f06 commit d56c237
Show file tree
Hide file tree
Showing 12 changed files with 600 additions and 63 deletions.
31 changes: 31 additions & 0 deletions app/cc_view/src/widget/MsgDetailsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

CC_DISABLE_WARNINGS()
#include <QtWidgets/QScrollBar>
#include <QtWidgets/QWidget>
CC_ENABLE_WARNINGS()

#include "cc_tools_qt/property/message.h"
Expand All @@ -38,6 +39,20 @@ const QString& getTitlePrefix()
return Str;
}

void updateValidityStyle(
QWidget& widget,
bool valid,
const QString& invalidStylesheet)
{
static const auto DefaultStylesheet = QWidget().styleSheet();
auto* stylesheet = &DefaultStylesheet;
if (!valid) {
stylesheet = &invalidStylesheet;
}

widget.setStyleSheet(*stylesheet);
}

} // namespace

MsgDetailsWidget::MsgDetailsWidget(QWidget* parentObj)
Expand Down Expand Up @@ -71,6 +86,10 @@ void MsgDetailsWidget::displayMessage(MessagePtr msg)
msgWidget.get(), SIGNAL(sigMsgUpdated()),
this, SIGNAL(sigMsgUpdated()));

connect(
msgWidget.get(), SIGNAL(sigMsgUpdated()),
this, SLOT(msgUpdated()));

m_displayedMsgWidget = msgWidget.get();

auto* scrollBar = m_ui.m_scrollArea->verticalScrollBar();
Expand All @@ -96,7 +115,10 @@ void MsgDetailsWidget::updateTitle(MessagePtr msg)
title.append(idStr);
title.append(")");
}

m_ui.m_groupBox->setTitle(title);
static const QString InvalidStylesheet("QGroupBox { color: red }");
updateValidityStyle(*m_ui.m_groupBox, msg->isValid(), InvalidStylesheet);
}

void MsgDetailsWidget::clear()
Expand Down Expand Up @@ -124,4 +146,13 @@ void MsgDetailsWidget::widgetScrolled(int value)
property::message::ScrollPos().setTo(value, *m_displayedMsg);
}

void MsgDetailsWidget::msgUpdated()
{
if (sender() != m_displayedMsg.get()) {
return;
}

updateTitle(m_displayedMsg);
}

} // namespace cc_tools_qt
1 change: 1 addition & 0 deletions app/cc_view/src/widget/MsgDetailsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public slots:

private slots:
void widgetScrolled(int value);
void msgUpdated();

private:
Ui::MsgDetailsWidget m_ui;
Expand Down
76 changes: 70 additions & 6 deletions demo/cc_plugin/message/Variants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ QVariantMap createProps_id()
return props.asMap();
}

QVariantMap createProps_var1()
QVariantMap createProps_length()
{
auto props =
cc::property::field::EnumValue()
.name("length")
.readOnly();
return props.asMap();
}

QVariantMap createProps_field1_var1()
{
using Field = VariantsFields::field1_var1;
auto props =
Expand All @@ -60,7 +69,7 @@ QVariantMap createProps_var1()
return props.asMap();
}

QVariantMap createProps_var2()
QVariantMap createProps_field1_var2()
{
using Field = VariantsFields::field1_var2;
auto props =
Expand All @@ -72,7 +81,7 @@ QVariantMap createProps_var2()
return props.asMap();
}

QVariantMap createProps_var3()
QVariantMap createProps_field1_var3()
{
using Field = VariantsFields::field1_var3;
auto props =
Expand All @@ -91,9 +100,63 @@ QVariantMap createProps_field1()
cc::property::field::ForField<Field>()
.name("field1")
.serialisedHidden()
.add(createProps_var1())
.add(createProps_var2())
.add(createProps_var3());
.add(createProps_field1_var1())
.add(createProps_field1_var2())
.add(createProps_field1_var3());
assert(props.members().size() == Field::FieldIdx_numOfValues);
return props.asMap();
}


QVariantMap createProps_field2_var1()
{
using Field = VariantsFields::field2_var1;
auto props =
cc::property::field::ForField<Field>()
.name("var1")
.add(createProps_id())
.add(createProps_length())
.add(cc::property::field::IntValue().name("value").asMap());
assert(props.members().size() == Field::FieldIdx_numOfValues);
return props.asMap();
}

QVariantMap createProps_field2_var2()
{
using Field = VariantsFields::field2_var2;
auto props =
cc::property::field::ForField<Field>()
.name("var2")
.add(createProps_id())
.add(createProps_length())
.add(cc::property::field::IntValue().name("value").asMap());
assert(props.members().size() == Field::FieldIdx_numOfValues);
return props.asMap();
}

QVariantMap createProps_field2_var3()
{
using Field = VariantsFields::field2_var3;
auto props =
cc::property::field::ForField<Field>()
.name("var3")
.add(createProps_id())
.add(createProps_length())
.add(cc::property::field::String().name("value").asMap());
assert(props.members().size() == Field::FieldIdx_numOfValues);
return props.asMap();
}

QVariantMap createProps_field2()
{
using Field = VariantsFields::field2;
auto props =
cc::property::field::ForField<Field>()
.name("field2")
.serialisedHidden()
.add(createProps_field2_var1())
.add(createProps_field2_var2())
.add(createProps_field2_var3());
assert(props.members().size() == Field::FieldIdx_numOfValues);
return props.asMap();
}
Expand All @@ -102,6 +165,7 @@ QVariantList createFieldsProperties()
{
QVariantList props;
props.append(createProps_field1());
props.append(createProps_field2());

assert(props.size() == Variants::FieldIdx_numOfValues);
return props;
Expand Down
12 changes: 12 additions & 0 deletions demo/include/demo/DefaultOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ struct DefaultOptions

/// @brief Extra options for @ref demo::message::VariantsFields::field1
using field1 = comms::option::EmptyOption;

/// @brief Extra options for @ref demo::message::VariantsFields::field2_var1
using field2_var1 = comms::option::EmptyOption;

/// @brief Extra options for @ref demo::message::VariantsFields::field2_var2
using field2_var2 = comms::option::EmptyOption;

/// @brief Extra options for @ref demo::message::VariantsFields::field2_var3
using field2_var3 = comms::option::EmptyOption;

/// @brief Extra options for @ref demo::message::VariantsFields::field2
using field2 = comms::option::EmptyOption;
};

/// @brief Extra options for @ref demo::message::Bitfields message
Expand Down
173 changes: 171 additions & 2 deletions demo/include/demo/message/Variants.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ struct VariantsFields
comms::option::FailOnInvalid<>
>;

/// @brief field used to identify the remaining length.
using lengthField =
comms::field::IntValue<
demo::FieldBase,
std::uint8_t>;

/// @brief First type that can be stored in @ref field1 variant field.
/// @details Identified by @ref VarId::Elem1 (0) value which is followed by
/// the 1 byte unsigned integer.
Expand Down Expand Up @@ -223,9 +229,172 @@ struct VariantsFields
COMMS_VARIANT_MEMBERS_NAMES(val1, val2, val3);
};

/// @brief First type that can be stored in @ref field2 variant field.
/// @details Identified by @ref VarId::Elem1 (0) value which is followed by
/// the length and 1 byte unsigned integer.
class field2_var1 : public
comms::field::Bundle<
demo::FieldBase,
std::tuple<
varIdField<VarId::Elem1>,
lengthField,
comms::field::IntValue<
demo::FieldBase,
std::uint8_t,
typename TOpt::message::VariantsFields::field1_var1
>
>,
comms::option::def::RemLengthMemberField<1>
>
{
using Base =
comms::field::Bundle<
demo::FieldBase,
std::tuple<
varIdField<VarId::Elem1>,
lengthField,
comms::field::IntValue<
demo::FieldBase,
std::uint8_t,
typename TOpt::message::VariantsFields::field1_var1
>
>,
comms::option::def::RemLengthMemberField<1>
>;
public:
/// @brief Allow access to internal fields.
/// @details See definition of @b COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE macro
/// related to @b comms::field::Bundle class from COMMS library
/// for details. @n
/// The names are:
/// @b id for @ref varIdField<VarId::Elem1>
/// @b length for @ref lengthField.
/// @b value for 1 byte unsigned integer field.
COMMS_FIELD_MEMBERS_NAMES(id, length, value);
};

/// @brief Second type that can be stored in @ref field2 variant field.
/// @details Identified by @ref VarId::Elem2 (1) value which is followed by
/// the 4 bytes unsigned integer.
class field2_var2 : public
comms::field::Bundle<
demo::FieldBase,
std::tuple<
varIdField<VarId::Elem2>,
lengthField,
comms::field::IntValue<
demo::FieldBase,
std::uint32_t,
typename TOpt::message::VariantsFields::field1_var2
>
>,
comms::option::def::RemLengthMemberField<1>
>
{
using Base =
comms::field::Bundle<
demo::FieldBase,
std::tuple<
varIdField<VarId::Elem2>,
lengthField,
comms::field::IntValue<
demo::FieldBase,
std::uint32_t,
typename TOpt::message::VariantsFields::field1_var2
>
>,
comms::option::def::RemLengthMemberField<1>
>;
public:
/// @brief Allow access to internal fields.
/// @details See definition of @b COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE macro
/// related to @b comms::field::Bundle class from COMMS library
/// for details. @n
/// The names are:
/// @b id for @ref varIdField<VarId::Elem1>
/// @b length for @ref lengthField.
/// @b value for 4 bytes unsigned integer field.
COMMS_FIELD_MEMBERS_NAMES(id, length, value);
};

/// @brief Third type that can be stored in @ref field2 variant field.
/// @details Identified by @ref VarId::Elem3 (2) value which is followed by
/// the string prefixed with its lengths (1 byte).
class field2_var3 : public
comms::field::Bundle<
demo::FieldBase,
std::tuple<
varIdField<VarId::Elem3>,
lengthField,
comms::field::String<demo::FieldBase>
>,
comms::option::def::RemLengthMemberField<1>
>
{
using Base =
comms::field::Bundle<
demo::FieldBase,
std::tuple<
varIdField<VarId::Elem3>,
lengthField,
comms::field::String<demo::FieldBase>
>,
comms::option::def::RemLengthMemberField<1>
>;
public:
/// @brief Allow access to internal fields.
/// @details See definition of @b COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE macro
/// related to @b comms::field::Bundle class from COMMS library
/// for details. @n
/// The names are:
/// @b id for @ref varIdField<VarId::Elem1>
/// @b length for @ref lengthField.
/// @b value for string field.
COMMS_FIELD_MEMBERS_NAMES(id, length, value);
};

/// @brief Variant field.
/// @details Can be one of the following:
/// @li @ref field2_var1
/// @li @ref field2_var2
/// @li @ref field2_var3
class field2 : public
comms::field::Variant<
demo::FieldBase,
std::tuple<
field2_var1,
field2_var2,
field2_var3
>,
typename TOpt::message::VariantsFields::field2
>
{
using Base =
comms::field::Variant<
demo::FieldBase,
std::tuple<
field2_var1,
field2_var2,
field2_var3
>,
typename TOpt::message::VariantsFields::field2
>;
public:
/// @brief Allow access to internal fields.
/// @details See definition of @b COMMS_VARIANT_MEMBERS_NAMES macro
/// related to @b comms::field::Variant class from COMMS library
/// for details. @n
/// The names are:
/// @b val1 for @ref field2_var1
/// @b val2 for @ref field2_var2
/// @b val3 for @ref field2_var3
COMMS_VARIANT_MEMBERS_NAMES(val1, val2, val3);
};

/// @brief All the fields bundled in std::tuple.
using All = std::tuple<
field1
field1,
field2
>;
};

Expand Down Expand Up @@ -268,7 +437,7 @@ class Variants : public
/// @details See definition of @b COMMS_MSG_FIELDS_NAMES macro
/// related to @b comms::MessageBase class from COMMS library
/// for details.
COMMS_MSG_FIELDS_NAMES(field1);
COMMS_MSG_FIELDS_NAMES(field1, field2);

// Check serialisation lengths
// For some reason VS2015 compiler fails when call to doMinLength()
Expand Down
Loading

0 comments on commit d56c237

Please sign in to comment.