refactor: implement unique_ptr in actionbox
This commit is contained in:
@@ -8,25 +8,28 @@
|
||||
#include "actionbox.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace QSint
|
||||
{
|
||||
|
||||
ActionBox::ActionBox(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
: QFrame(parent),
|
||||
dataLayout(std::make_unique<QVBoxLayout>())
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
ActionBox::ActionBox(const QString & headerText, QWidget *parent) :
|
||||
QFrame(parent)
|
||||
ActionBox::ActionBox(const QString & headerText, QWidget *parent)
|
||||
: QFrame(parent),
|
||||
dataLayout(std::make_unique<QVBoxLayout>() )
|
||||
{
|
||||
init(headerText);
|
||||
}
|
||||
|
||||
ActionBox::ActionBox(const QPixmap & icon, const QString & headerText, QWidget *parent) :
|
||||
QFrame(parent)
|
||||
ActionBox::ActionBox(const QPixmap & icon, const QString & headerText, QWidget *parent)
|
||||
: QFrame(parent),
|
||||
dataLayout(std::make_unique<QVBoxLayout>())
|
||||
{
|
||||
init(headerText);
|
||||
setIcon(icon);
|
||||
@@ -45,8 +48,7 @@ void ActionBox::init(const QString &headerText)
|
||||
iconLayout->addWidget(iconLabel);
|
||||
iconLayout->addStretch();
|
||||
|
||||
dataLayout = new QVBoxLayout();
|
||||
mainLayout->addLayout(dataLayout);
|
||||
mainLayout->addLayout(dataLayout.get());
|
||||
|
||||
headerLabel = createItem(headerText);
|
||||
headerLabel->setProperty("class", "header");
|
||||
@@ -175,5 +177,4 @@ QSize ActionBox::minimumSizeHint() const
|
||||
return {150,65};
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
|
||||
/** Returns default layout used for actions (typically it's QVBoxLayout).
|
||||
*/
|
||||
inline QLayout* itemLayout() const { return dataLayout; }
|
||||
inline QLayout* itemLayout() const { return dataLayout.get(); }
|
||||
|
||||
/** Adds layout \a l to the default layout.
|
||||
*/
|
||||
@@ -247,9 +247,10 @@ public:
|
||||
protected:
|
||||
void init(const QString &headerText = QString());
|
||||
|
||||
QVBoxLayout *dataLayout;
|
||||
QLabel *iconLabel;
|
||||
ActionLabel *headerLabel;
|
||||
std::unique_ptr<QVBoxLayout> dataLayout;
|
||||
QLabel *iconLabel = nullptr;
|
||||
ActionLabel *headerLabel = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user