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

View File

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