Skip to content

Commit

Permalink
cppcheck: Fix several "use initialization list" warnings in mythdialo…
Browse files Browse the repository at this point in the history
…gbox.

Move the entire body of the function to the initialization list, and
then move the entire thing to the header file since its just one big
initialization. Several of the values were converted to default member
initialization values.

clang-tidy suggested the use of std::move.
  • Loading branch information
linuxdude42 committed Jan 3, 2023
1 parent 43f16b1 commit 4fa0592
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 45 deletions.
36 changes: 0 additions & 36 deletions mythtv/libs/libmythui/mythdialogbox.cpp
Expand Up @@ -774,42 +774,6 @@ void MythSpinBoxDialog::sendResult()

/////////////////////////////////////////////////////////////////////


/** \fn MythUISearchDialog::MythUISearchDialog(MythScreenStack*,
const QString&,
const QStringList&,
bool matchAnywhere,
const QString&)
* \brief the classes constructor
* \param parent the MythScreenStack this widget belongs to
* \param title the text to show as the title
* \param list the list of text strings to search
* \param matchAnywhere if true will match the input text anywhere in the string.
if false will match only strings that start with the input text.
Default is false.
* \param defaultValue The initial value for the input text. Default is ""
*/
MythUISearchDialog::MythUISearchDialog(MythScreenStack *parent,
const QString &title,
const QStringList &list,
bool matchAnywhere,
const QString &defaultValue)
: MythScreenType(parent, "mythsearchdialogpopup")
{
m_list = list;
m_matchAnywhere = matchAnywhere;
m_title = title;
m_defaultValue = defaultValue;

m_titleText = nullptr;
m_matchesText = nullptr;
m_textEdit = nullptr;
m_itemList = nullptr;

m_id = "";
m_retObject = nullptr;
}

bool MythUISearchDialog::Create(void)
{
if (!CopyWindowFromBase("MythSearchDialog", this))
Expand Down
33 changes: 24 additions & 9 deletions mythtv/libs/libmythui/mythdialogbox.h
Expand Up @@ -401,11 +401,26 @@ class MUI_PUBLIC MythUISearchDialog : public MythScreenType
Q_OBJECT

public:
/** \brief the classes constructor
* \param parent the MythScreenStack this widget belongs to
* \param title the text to show as the title
* \param list the list of text strings to search
* \param matchAnywhere if true will match the input text anywhere in the string.
* if false will match only strings that start with the input text.
* Default is false.
* \param defaultValue The initial value for the input text. Default is ""
*/
MythUISearchDialog(MythScreenStack *parent,
const QString &title,
const QStringList &list,
QString title,
QStringList list,
bool matchAnywhere = false,
const QString &defaultValue = "");
QString defaultValue = "")
: MythScreenType(parent, "mythsearchdialogpopup"),
m_title(std::move(title)),
m_defaultValue(std::move(defaultValue)),
m_list(std::move(list)),
m_matchAnywhere(matchAnywhere),
m_id("") {};

bool Create(void) override; // MythScreenType
void SetReturnEvent(QObject *retobject, const QString &resultid);
Expand All @@ -414,17 +429,17 @@ class MUI_PUBLIC MythUISearchDialog : public MythScreenType
void haveResult(QString);

private:
MythUIButtonList *m_itemList;
MythUITextEdit *m_textEdit;
MythUIText *m_titleText;
MythUIText *m_matchesText;
MythUIButtonList *m_itemList { nullptr };
MythUITextEdit *m_textEdit { nullptr };
MythUIText *m_titleText { nullptr };
MythUIText *m_matchesText { nullptr };

QString m_title;
QString m_defaultValue;
QStringList m_list;
bool m_matchAnywhere;
bool m_matchAnywhere { false };

QObject *m_retObject;
QObject *m_retObject { nullptr };
QString m_id;

private slots:
Expand Down

0 comments on commit 4fa0592

Please sign in to comment.