Commit 5557b845 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Const'ify pointer + add missing Q_REQUIRED_RESULT

parent 404eb2f4
Pipeline #59890 passed with stage
in 16 minutes and 29 seconds
......@@ -29,12 +29,13 @@ void SelectConvertParameterWidget::setCode(const QStringList &code, QString &err
return;
}
if (code.count() < 2) {
const int codeCount{code.count()};
if (codeCount < 2) {
error += i18n("Not enough arguments for SelectConvertParameterWidget. Expected 2 arguments.") + QLatin1Char('\n');
qCDebug(LIBKSIEVE_LOG) << " SelectConvertParameterWidget::setCode parsing error ?";
return;
}
if (code.count() > 2) {
if (codeCount > 2) {
error += i18n("Too many arguments for SelectConvertParameterWidget, \"%1\"", code.count()) + QLatin1Char('\n');
qCDebug(LIBKSIEVE_LOG) << " too many argument " << code.count();
}
......@@ -55,7 +56,7 @@ QString SelectConvertParameterWidget::code() const
void SelectConvertParameterWidget::initialize()
{
QBoxLayout *hbox = new QHBoxLayout(this);
auto hbox = new QHBoxLayout(this);
hbox->setContentsMargins({});
mWidth = new QSpinBox(this);
mWidth->setSuffix(i18n(" px"));
......
......@@ -12,11 +12,11 @@
using namespace KSieveUi;
RegexpEditorLineEdit::RegexpEditorLineEdit(QWidget *parent)
: KSieveUi::AbstractRegexpEditorLineEdit(parent)
, mLineEdit(new QLineEdit(this))
{
auto mainLayout = new QHBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mainLayout->setContentsMargins({});
mLineEdit = new QLineEdit(this);
new KPIM::LineEditCatchReturnKey(mLineEdit, this);
mLineEdit->setObjectName(QStringLiteral("lineedit"));
connect(mLineEdit, &QLineEdit::textChanged, this, &RegexpEditorLineEdit::textChanged);
......
......@@ -26,7 +26,7 @@ public:
void setPlaceholderText(const QString &str) override;
private:
QLineEdit *mLineEdit = nullptr;
QLineEdit *const mLineEdit;
};
}
......@@ -15,6 +15,8 @@ using namespace KSieveUi;
SelectRelationalMatchType::SelectRelationalMatchType(QWidget *parent)
: QWidget(parent)
, mType(new QComboBox(this))
, mMatch(new QComboBox(this))
{
initialize();
}
......@@ -52,13 +54,11 @@ void SelectRelationalMatchType::initialize()
auto lay = new QHBoxLayout(this);
lay->setContentsMargins({});
mType = new QComboBox(this);
mType->addItem(i18n("Value"), QStringLiteral(":value"));
mType->addItem(i18n("Count"), QStringLiteral(":count"));
lay->addWidget(mType);
connect(mType, QOverload<int>::of(&QComboBox::activated), this, &SelectRelationalMatchType::valueChanged);
mMatch = new QComboBox(this);
mMatch->addItem(i18n("Greater than"), QStringLiteral("gt"));
mMatch->addItem(i18n("Greater than or equal"), QStringLiteral("ge"));
mMatch->addItem(i18n("Less than"), QStringLiteral("lt"));
......
......@@ -25,8 +25,8 @@ Q_SIGNALS:
private:
void initialize();
QComboBox *mType = nullptr;
QComboBox *mMatch = nullptr;
QComboBox *const mType;
QComboBox *const mMatch;
};
}
......@@ -14,17 +14,17 @@ using namespace KSieveUi;
SelectSizeWidget::SelectSizeWidget(QWidget *parent)
: QWidget(parent)
, mSpinBoxSize(new QSpinBox(this))
, mSelectSizeType(new SelectSizeTypeComboBox(this))
{
auto hbox = new QHBoxLayout(this);
hbox->setContentsMargins({});
mSpinBoxSize = new QSpinBox(this);
mSpinBoxSize->setMinimum(1);
mSpinBoxSize->setMaximum(99999);
hbox->addWidget(mSpinBoxSize);
connect(mSpinBoxSize, QOverload<int>::of(&QSpinBox::valueChanged), this, &SelectSizeWidget::valueChanged);
mSelectSizeType = new SelectSizeTypeComboBox(this);
connect(mSelectSizeType, &SelectSizeTypeComboBox::valueChanged, this, &SelectSizeWidget::valueChanged);
hbox->addWidget(mSelectSizeType);
}
......
......@@ -25,13 +25,13 @@ using namespace KSieveUi;
SieveEditorGraphicalModeWidget::SieveEditorGraphicalModeWidget(QWidget *parent)
: SieveEditorGraphicalModeWidgetAbstract::SieveEditorGraphicalModeWidgetAbstract(parent)
, mSieveScript(new SieveScriptListBox(i18n("Sieve Script"), this))
, mSplitter(new QSplitter)
{
auto vlay = new QVBoxLayout(this);
vlay->setContentsMargins({});
mSplitter = new QSplitter;
mSplitter->setChildrenCollapsible(false);
mSieveScript = new SieveScriptListBox(i18n("Sieve Script"));
mSieveScript->setSieveEditorGraphicalModeWidget(this);
connect(mSieveScript, &SieveScriptListBox::valueChanged, this, &SieveEditorGraphicalModeWidget::valueChanged);
connect(mSieveScript, &SieveScriptListBox::addNewPage, this, &SieveEditorGraphicalModeWidget::slotAddScriptPage);
......
......@@ -55,9 +55,9 @@ private Q_SLOTS:
private:
QStringList mCapabilities;
QStringList mListOfIncludeFile;
SieveScriptListBox *mSieveScript = nullptr;
SieveScriptListBox *const mSieveScript;
QStackedWidget *mStackWidget = nullptr;
QSplitter *mSplitter = nullptr;
QSplitter *const mSplitter;
SieveEditorParsingMissingFeatureWarning *mSieveParsingWarning = nullptr;
};
}
......
......@@ -27,24 +27,24 @@ using namespace KSieveUi;
SieveForEveryPartWidget::SieveForEveryPartWidget(QWidget *parent)
: SieveWidgetPageAbstract(parent)
, mForLoop(new QCheckBox(i18n("Add ForEveryPart loop"), this))
, mName(new LineEditValidator(this))
, mHelpButton(new SieveHelpButton(this))
{
auto mainLayout = new QVBoxLayout(this);
auto lay = new QHBoxLayout;
mainLayout->addLayout(lay);
mainLayout->addStretch(1);
mHelpButton = new SieveHelpButton(this);
lay->addWidget(mHelpButton);
connect(mHelpButton, &SieveHelpButton::clicked, this, &SieveForEveryPartWidget::slotHelp);
mForLoop = new QCheckBox(i18n("Add ForEveryPart loop"), this);
connect(mForLoop, &QCheckBox::toggled, this, &SieveForEveryPartWidget::valueChanged);
lay->addWidget(mForLoop);
auto lab = new QLabel(i18n("Name (optional):"), this);
lay->addWidget(lab);
mName = new LineEditValidator(this);
new KPIM::LineEditCatchReturnKey(mName, this);
connect(mName, &QLineEdit::textChanged, this, &SieveForEveryPartWidget::valueChanged);
mName->setEnabled(false);
......
......@@ -18,11 +18,11 @@ using namespace KSieveUi;
SieveScriptDescriptionDialog::SieveScriptDescriptionDialog(QWidget *parent)
: QDialog(parent)
, mEdit(new KPIMTextEdit::PlainTextEditorWidget(this))
{
setWindowTitle(i18nc("@title:window", "Description"));
auto mainLayout = new QVBoxLayout(this);
mEdit = new KPIMTextEdit::PlainTextEditorWidget(this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
......
......@@ -85,10 +85,10 @@ QString SieveScriptListItem::generatedScript(QStringList &required) const
SieveScriptListBox::SieveScriptListBox(const QString &title, QWidget *parent)
: QGroupBox(title, parent)
, mSieveListScript(new QListWidget(this))
{
auto layout = new QVBoxLayout(this);
layout->setObjectName(QStringLiteral("layout"));
mSieveListScript = new QListWidget(this);
mSieveListScript->setObjectName(QStringLiteral("mSieveListScript"));
mSieveListScript->setDragDropMode(QAbstractItemView::InternalMove);
mSieveListScript->setContextMenuPolicy(Qt::CustomContextMenu);
......
......@@ -81,10 +81,10 @@ private:
void loadBlock(QXmlStreamReader &n, SieveScriptPage *currentPage, ParseSieveScriptTypeBlock typeBlock, QString &error);
void clear();
SieveScriptPage *createNewScript(const QString &newName, const QString &description = QString());
QString createUniqName();
Q_REQUIRED_RESULT SieveScriptPage *createNewScript(const QString &newName, const QString &description = QString());
Q_REQUIRED_RESULT QString createUniqName();
SieveEditorGraphicalModeWidget *mSieveGraphicalModeWidget = nullptr;
QListWidget *mSieveListScript = nullptr;
QListWidget *const mSieveListScript;
QPushButton *mBtnNew = nullptr;
QPushButton *mBtnDelete = nullptr;
QPushButton *mBtnRename = nullptr;
......
......@@ -43,7 +43,7 @@ private Q_SLOTS:
void slotCloseTab(int);
private:
SieveScriptBlockWidget *createScriptBlock(KSieveUi::SieveWidgetPageAbstract::PageType type);
Q_REQUIRED_RESULT SieveScriptBlockWidget *createScriptBlock(KSieveUi::SieveWidgetPageAbstract::PageType type);
Q_REQUIRED_RESULT bool hasAnElseBlock() const;
Q_REQUIRED_RESULT QString blockName(SieveWidgetPageAbstract::PageType type) const;
......
......@@ -19,11 +19,11 @@
using namespace KSieveUi;
SieveScriptParsingErrorDialog::SieveScriptParsingErrorDialog(QWidget *parent)
: QDialog(parent)
, mTextEdit(new KPIMTextEdit::RichTextEditorWidget(this))
{
setWindowTitle(i18nc("@title:window", "Sieve Parsing Error"));
auto mainLayout = new QVBoxLayout(this);
mTextEdit = new KPIMTextEdit::RichTextEditorWidget(this);
mTextEdit->setReadOnly(true);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
......
......@@ -28,6 +28,6 @@ private:
void writeConfig();
private:
KPIMTextEdit::RichTextEditorWidget *mTextEdit = nullptr;
KPIMTextEdit::RichTextEditorWidget *const mTextEdit;
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment