File indexing completed on 2025-01-19 04:47:00
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "adblockfilterwidget.h" 0008 #include "adblockfiltertreeview.h" 0009 0010 #include <KLineEditEventHandler> 0011 #include <KLocalizedString> 0012 #include <QLineEdit> 0013 #include <QVBoxLayout> 0014 0015 AdblockFilterWidget::AdblockFilterWidget(QWidget *parent) 0016 : QWidget{parent} 0017 , mAdblockFilterListView(new AdblockFilterTreeView(this)) 0018 , mSearchLineEdit(new QLineEdit(this)) 0019 { 0020 auto mainLayout = new QVBoxLayout(this); 0021 mainLayout->setObjectName(QLatin1StringView("mainLayout")); 0022 mainLayout->setContentsMargins({}); 0023 0024 mSearchLineEdit->setObjectName(QLatin1StringView("mSearchLineEdit")); 0025 mainLayout->addWidget(mSearchLineEdit); 0026 mSearchLineEdit->setPlaceholderText(i18n("Search...")); 0027 mSearchLineEdit->setClearButtonEnabled(true); 0028 KLineEditEventHandler::catchReturnKey(mSearchLineEdit); 0029 0030 mAdblockFilterListView->setObjectName(QLatin1StringView("mAdblockFilterListView")); 0031 mainLayout->addWidget(mAdblockFilterListView); 0032 connect(mSearchLineEdit, &QLineEdit::textChanged, mAdblockFilterListView, &AdblockFilterTreeView::setFilterString); 0033 connect(mAdblockFilterListView, &AdblockFilterTreeView::settingsChanged, this, &AdblockFilterWidget::settingsChanged); 0034 } 0035 0036 AdblockFilterWidget::~AdblockFilterWidget() = default; 0037 0038 void AdblockFilterWidget::loadSettings() 0039 { 0040 mAdblockFilterListView->loadSettings(); 0041 } 0042 0043 void AdblockFilterWidget::saveSettings() 0044 { 0045 mAdblockFilterListView->saveSettings(); 0046 } 0047 0048 #include "moc_adblockfilterwidget.cpp"