File indexing completed on 2024-12-29 04:54:40

0001 /*
0002    SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "regexpeditorlineedit.h"
0008 #include <KLineEditEventHandler>
0009 #include <QHBoxLayout>
0010 #include <QLineEdit>
0011 
0012 using namespace KSieveUi;
0013 RegexpEditorLineEdit::RegexpEditorLineEdit(QWidget *parent)
0014     : KSieveUi::AbstractRegexpEditorLineEdit(parent)
0015     , mLineEdit(new QLineEdit(this))
0016 {
0017     auto mainLayout = new QHBoxLayout(this);
0018     mainLayout->setObjectName(QLatin1StringView("mainlayout"));
0019     mainLayout->setContentsMargins({});
0020     KLineEditEventHandler::catchReturnKey(mLineEdit);
0021     mLineEdit->setObjectName(QLatin1StringView("lineedit"));
0022     connect(mLineEdit, &QLineEdit::textChanged, this, &RegexpEditorLineEdit::textChanged);
0023     mainLayout->addWidget(mLineEdit);
0024 }
0025 
0026 RegexpEditorLineEdit::~RegexpEditorLineEdit() = default;
0027 
0028 void RegexpEditorLineEdit::switchToRegexpEditorLineEdit(bool regexpEditor)
0029 {
0030     Q_UNUSED(regexpEditor)
0031     // Nothing here
0032 }
0033 
0034 void KSieveUi::RegexpEditorLineEdit::setCode(const QString &str)
0035 {
0036     mLineEdit->setText(str);
0037 }
0038 
0039 QString KSieveUi::RegexpEditorLineEdit::code() const
0040 {
0041     return mLineEdit->text();
0042 }
0043 
0044 void KSieveUi::RegexpEditorLineEdit::setClearButtonEnabled(bool b)
0045 {
0046     mLineEdit->setClearButtonEnabled(b);
0047 }
0048 
0049 void KSieveUi::RegexpEditorLineEdit::setPlaceholderText(const QString &str)
0050 {
0051     mLineEdit->setPlaceholderText(str);
0052 }
0053 
0054 #include "moc_regexpeditorlineedit.cpp"