File indexing completed on 2024-12-08 04:34:09

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "bannerinfolistsearchlinewidget.h"
0008 #include <KLineEditEventHandler>
0009 #include <KLocalizedString>
0010 #include <QCheckBox>
0011 #include <QHBoxLayout>
0012 #include <QLineEdit>
0013 
0014 BannerInfoListSearchLineWidget::BannerInfoListSearchLineWidget(QWidget *parent)
0015     : QWidget{parent}
0016     , mSearchLineEdit(new QLineEdit(this))
0017     , mOnlyUnReadCheckBox(new QCheckBox(i18n("Show Unread"), this))
0018 {
0019     auto mainLayout = new QHBoxLayout(this);
0020     mainLayout->setContentsMargins({});
0021     mainLayout->setObjectName(QStringLiteral("mainLayout"));
0022 
0023     mSearchLineEdit->setObjectName(QStringLiteral("mSearchLineEdit"));
0024     mSearchLineEdit->setPlaceholderText(i18n("Search..."));
0025     mSearchLineEdit->setClearButtonEnabled(true);
0026     KLineEditEventHandler::catchReturnKey(mSearchLineEdit);
0027     mainLayout->addWidget(mSearchLineEdit);
0028     connect(mSearchLineEdit, &QLineEdit::textChanged, this, &BannerInfoListSearchLineWidget::filterChanged);
0029 
0030     mOnlyUnReadCheckBox->setObjectName(QStringLiteral("mOnlyUnReadCheckBox"));
0031     mainLayout->addWidget(mOnlyUnReadCheckBox);
0032     connect(mOnlyUnReadCheckBox, &QCheckBox::clicked, this, &BannerInfoListSearchLineWidget::filterChanged);
0033 }
0034 
0035 BannerInfoListSearchLineWidget::~BannerInfoListSearchLineWidget() = default;
0036 
0037 QString BannerInfoListSearchLineWidget::searchText() const
0038 {
0039     return mSearchLineEdit->text();
0040 }
0041 
0042 bool BannerInfoListSearchLineWidget::showOnlyUnread() const
0043 {
0044     return mOnlyUnReadCheckBox->isChecked();
0045 }
0046 
0047 #include "moc_bannerinfolistsearchlinewidget.cpp"