CLinkDialog: Make use of in-class initializers where applicable

This commit is contained in:
Lioncash 2020-06-28 04:01:27 -04:00
parent 968fc70cbf
commit 0d17e8686d
2 changed files with 22 additions and 31 deletions

View File

@ -6,17 +6,10 @@
#include "Editor/Undo/CEditLinkCommand.h" #include "Editor/Undo/CEditLinkCommand.h"
#include <Core/Resource/Script/CScriptObject.h> #include <Core/Resource/Script/CScriptObject.h>
CLinkDialog::CLinkDialog(CWorldEditor *pEditor, QWidget *pParent /*= 0*/) CLinkDialog::CLinkDialog(CWorldEditor *pEditor, QWidget *pParent)
: QDialog(pParent) : QDialog(pParent)
, ui(new Ui::CLinkDialog)
, mpEditor(pEditor) , mpEditor(pEditor)
, mpGame(nullptr) , ui(std::make_unique<Ui::CLinkDialog>())
, mpSender(nullptr)
, mpReceiver(nullptr)
, mSenderStateModel(CStateMessageModel::EType::States, this)
, mReceiverMessageModel(CStateMessageModel::EType::Messages, this)
, mIsPicking(false)
, mpEditLink(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->SenderStateComboBox->setModel(&mSenderStateModel); ui->SenderStateComboBox->setModel(&mSenderStateModel);
@ -29,10 +22,7 @@ CLinkDialog::CLinkDialog(CWorldEditor *pEditor, QWidget *pParent /*= 0*/)
connect(ui->ReceiverPickFromList, SIGNAL(clicked()), this, SLOT(OnPickFromListClicked())); connect(ui->ReceiverPickFromList, SIGNAL(clicked()), this, SLOT(OnPickFromListClicked()));
} }
CLinkDialog::~CLinkDialog() CLinkDialog::~CLinkDialog() = default;
{
delete ui;
}
void CLinkDialog::resizeEvent(QResizeEvent *) void CLinkDialog::resizeEvent(QResizeEvent *)
{ {

View File

@ -12,24 +12,25 @@ class CLinkDialog : public QDialog
Q_OBJECT Q_OBJECT
CWorldEditor *mpEditor; CWorldEditor *mpEditor;
CGameTemplate *mpGame; CGameTemplate *mpGame = nullptr;
CScriptObject *mpSender; CScriptObject *mpSender = nullptr;
CScriptObject *mpReceiver; CScriptObject *mpReceiver = nullptr;
CLink *mpEditLink; CLink *mpEditLink = nullptr;
CStateMessageModel mSenderStateModel; CStateMessageModel mSenderStateModel{CStateMessageModel::EType::States, this};
CStateMessageModel mReceiverMessageModel; CStateMessageModel mReceiverMessageModel{CStateMessageModel::EType::Messages, this};
bool mIsPicking; bool mIsPicking = false;
Ui::CLinkDialog *ui; std::unique_ptr<Ui::CLinkDialog> ui;
public: public:
explicit CLinkDialog(CWorldEditor *pEditor, QWidget *parent = 0); explicit CLinkDialog(CWorldEditor *pEditor, QWidget *parent = nullptr);
~CLinkDialog(); ~CLinkDialog() override;
void resizeEvent(QResizeEvent *);
void showEvent(QShowEvent *); void resizeEvent(QResizeEvent*) override;
void closeEvent(QCloseEvent *); void showEvent(QShowEvent*) override;
void closeEvent(QCloseEvent*) override;
void NewLink(CScriptObject *pSender, CScriptObject *pReceiver); void NewLink(CScriptObject *pSender, CScriptObject *pReceiver);
void EditLink(CLink *pLink); void EditLink(CLink *pLink);
@ -44,11 +45,11 @@ public:
void UpdateSenderNameLabel(); void UpdateSenderNameLabel();
void UpdateReceiverNameLabel(); void UpdateReceiverNameLabel();
inline CScriptObject* Sender() const { return mpSender; } CScriptObject* Sender() const { return mpSender; }
inline CScriptObject* Receiver() const { return mpReceiver; } CScriptObject* Receiver() const { return mpReceiver; }
inline bool IsPicking() const { return mIsPicking; } bool IsPicking() const { return mIsPicking; }
inline bool IsPickingSender() const { return mIsPicking && ui->SenderPickFromViewport->isChecked(); } bool IsPickingSender() const { return mIsPicking && ui->SenderPickFromViewport->isChecked(); }
inline bool IsPickingReceiver() const { return mIsPicking && ui->ReceiverPickFromViewport->isChecked(); } bool IsPickingReceiver() const { return mIsPicking && ui->ReceiverPickFromViewport->isChecked(); }
public slots: public slots:
void accept(); void accept();