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 @@
CommandPad::CommandPad() : Module(ModuleId::COMMAND_PAD) { setupUi(); }
CommandPad::~CommandPad()
{
delete messagesListComboBox;
for (auto key : formElements.keys())
delete formElements[key];
}
CommandPad::~CommandPad() {}
XmlObject CommandPad::toXmlObject()
{
......@@ -61,11 +56,11 @@ void CommandPad::setupUi()
QVBoxLayout *outerLayout = new QVBoxLayout;
outerLayout->addStretch();
messagesListComboBox = new QComboBox;
messagesListComboBox = std::make_unique<QComboBox>();
messagesListComboBox->setSizePolicy(
QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
messagesListComboBox->addItems(MessagesList::messagesList);
outerLayout->addWidget(messagesListComboBox);
outerLayout->addWidget(messagesListComboBox.get());
QGridLayout *formGridLayout = new QGridLayout;
outerLayout->addLayout(formGridLayout);
......@@ -81,7 +76,7 @@ void CommandPad::setupUi()
currentMessage = "PING_TC";
messagesListComboBox->setCurrentText(currentMessage);
connect(messagesListComboBox, &QComboBox::currentTextChanged, this,
connect(messagesListComboBox.get(), &QComboBox::currentTextChanged, this,
[=](QString key)
{
if (formElements.contains(key))
......
......@@ -38,6 +38,6 @@ private:
void setupUi();
QString currentMessage;
QComboBox* messagesListComboBox;
QMap<QString, MessageFormElement*> formElements;
std::unique_ptr<QComboBox> messagesListComboBox;
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