Skip to content
Snippets Groups Projects
Commit 8d6df420 authored by Raul Radu's avatar Raul Radu
Browse files

[Modules] CommandPad using smart pointers

parent 65588da9
Branches
No related tags found
No related merge requests found
...@@ -24,12 +24,7 @@ ...@@ -24,12 +24,7 @@
CommandPad::CommandPad() : Module(ModuleId::COMMAND_PAD) { setupUi(); } CommandPad::CommandPad() : Module(ModuleId::COMMAND_PAD) { setupUi(); }
CommandPad::~CommandPad() CommandPad::~CommandPad() {}
{
delete messagesListComboBox;
for (auto key : formElements.keys())
delete formElements[key];
}
XmlObject CommandPad::toXmlObject() XmlObject CommandPad::toXmlObject()
{ {
...@@ -61,11 +56,11 @@ void CommandPad::setupUi() ...@@ -61,11 +56,11 @@ void CommandPad::setupUi()
QVBoxLayout *outerLayout = new QVBoxLayout; QVBoxLayout *outerLayout = new QVBoxLayout;
outerLayout->addStretch(); outerLayout->addStretch();
messagesListComboBox = new QComboBox; messagesListComboBox = std::make_unique<QComboBox>();
messagesListComboBox->setSizePolicy( messagesListComboBox->setSizePolicy(
QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
messagesListComboBox->addItems(MessagesList::messagesList); messagesListComboBox->addItems(MessagesList::messagesList);
outerLayout->addWidget(messagesListComboBox); outerLayout->addWidget(messagesListComboBox.get());
QGridLayout *formGridLayout = new QGridLayout; QGridLayout *formGridLayout = new QGridLayout;
outerLayout->addLayout(formGridLayout); outerLayout->addLayout(formGridLayout);
...@@ -81,7 +76,7 @@ void CommandPad::setupUi() ...@@ -81,7 +76,7 @@ void CommandPad::setupUi()
currentMessage = "PING_TC"; currentMessage = "PING_TC";
messagesListComboBox->setCurrentText(currentMessage); messagesListComboBox->setCurrentText(currentMessage);
connect(messagesListComboBox, &QComboBox::currentTextChanged, this, connect(messagesListComboBox.get(), &QComboBox::currentTextChanged, this,
[=](QString key) [=](QString key)
{ {
if (formElements.contains(key)) if (formElements.contains(key))
......
...@@ -38,6 +38,6 @@ private: ...@@ -38,6 +38,6 @@ private:
void setupUi(); void setupUi();
QString currentMessage; QString currentMessage;
QComboBox* messagesListComboBox; std::unique_ptr<QComboBox> messagesListComboBox;
QMap<QString, MessageFormElement*> formElements; QMap<QString, std::unique_ptr<MessageFormElement>> formElements;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment