From kde-commits Tue Sep 11 09:16:11 2018 From: Friedrich W. H. Kossebau Date: Tue, 11 Sep 2018 09:16:11 +0000 To: kde-commits Subject: [kdevelop] plugins: Port away from deprecated KFilterProxySearchLine Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=153665738930319 Git commit 81278baa7c03d292a60bb40826bc577c5078dbc2 by Friedrich W. H. Koss= ebau. Committed on 11/09/2018 at 09:16. Pushed by kossebau into branch 'master'. Port away from deprecated KFilterProxySearchLine Summary: The clazy & cppcheck config UIs did not even make use of attaching the search line to a proxy model. Reviewers: #kdevelop, antonanikin Reviewed By: #kdevelop, antonanikin Subscribers: antonanikin, kdevelop-devel Tags: #kdevelop Differential Revision: https://phabricator.kde.org/D15415 M +2 -2 plugins/clazy/config/commandlinewidget.cpp M +8 -8 plugins/clazy/config/commandlinewidget.ui M +0 -1 plugins/cppcheck/CMakeLists.txt M +2 -2 plugins/cppcheck/config/projectconfigpage.cpp M +8 -6 plugins/cppcheck/config/projectconfigpage.ui M +5 -1 plugins/kdeprovider/CMakeLists.txt A +58 -0 plugins/kdeprovider/filterproxysearchline.cpp [License: = LGPL (v2+)] C +24 -21 plugins/kdeprovider/filterproxysearchline.h [from: plugins/k= deprovider/kdeproviderwidget.h - 052% similarity] M +6 -3 plugins/kdeprovider/kdeproviderwidget.cpp M +1 -1 plugins/kdeprovider/kdeproviderwidget.h https://commits.kde.org/kdevelop/81278baa7c03d292a60bb40826bc577c5078dbc2 diff --git a/plugins/clazy/config/commandlinewidget.cpp b/plugins/clazy/con= fig/commandlinewidget.cpp index c97ce9f9a4..644e479e8b 100644 --- a/plugins/clazy/config/commandlinewidget.cpp +++ b/plugins/clazy/config/commandlinewidget.cpp @@ -34,7 +34,7 @@ CommandLineWidget::CommandLineWidget(QWidget* parent) m_ui->setupUi(this); m_ui->cmdEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedF= ont)); = - connect(m_ui->cmdFilter->lineEdit(), &QLineEdit::textChanged, this, &C= ommandLineWidget::updateCommandLine); + connect(m_ui->cmdFilter, &QLineEdit::textChanged, this, &CommandLineWi= dget::updateCommandLine); connect(m_ui->cmdBreak, &QCheckBox::stateChanged, this, &CommandLineWi= dget::updateCommandLine); } = @@ -56,7 +56,7 @@ void CommandLineWidget::updateCommandLine() commandLine.replace(QLatin1String(","), QLatin1String("\n,")); } = - auto filterText =3D m_ui->cmdFilter->lineEdit()->text(); + auto filterText =3D m_ui->cmdFilter->text(); if (!filterText.isEmpty()) { QStringList lines =3D commandLine.split(QLatin1Char('\n')); QMutableStringListIterator i(lines); diff --git a/plugins/clazy/config/commandlinewidget.ui b/plugins/clazy/conf= ig/commandlinewidget.ui index c2241b2174..0bb1dff233 100644 --- a/plugins/clazy/config/commandlinewidget.ui +++ b/plugins/clazy/config/commandlinewidget.ui @@ -32,7 +32,14 @@ - + + + Search + + + true + + @@ -55,13 +62,6 @@ - - - KFilterProxySearchLine - QWidget -
kfilterproxysearchline.h
-
-
diff --git a/plugins/cppcheck/CMakeLists.txt b/plugins/cppcheck/CMakeLists.= txt index 8e77f72b2d..8aebb189b0 100644 --- a/plugins/cppcheck/CMakeLists.txt +++ b/plugins/cppcheck/CMakeLists.txt @@ -52,7 +52,6 @@ kdevplatform_add_plugin(kdevcppcheck ) target_link_libraries(kdevcppcheck kdevcppcheck_core - KF5::ItemViews ) = ecm_install_icons(ICONS icons/128-apps-cppcheck.png diff --git a/plugins/cppcheck/config/projectconfigpage.cpp b/plugins/cppche= ck/config/projectconfigpage.cpp index 6b76c40117..a527b0c035 100644 --- a/plugins/cppcheck/config/projectconfigpage.cpp +++ b/plugins/cppcheck/config/projectconfigpage.cpp @@ -43,7 +43,7 @@ ProjectConfigPage::ProjectConfigPage(KDevelop::IPlugin* p= lugin, KDevelop::IProje ui->commandLine->setFont(QFontDatabase::systemFont(QFontDatabase::Fixe= dFont)); = connect(this, &ProjectConfigPage::changed, this, &ProjectConfigPage::u= pdateCommandLine); - connect(ui->commandLineFilter->lineEdit(), &QLineEdit::textChanged, th= is, &ProjectConfigPage::updateCommandLine); + connect(ui->commandLineFilter, &QLineEdit::textChanged, this, &Project= ConfigPage::updateCommandLine); connect(ui->commandLineBreaks, &QCheckBox::stateChanged, this, &Projec= tConfigPage::updateCommandLine); } = @@ -105,7 +105,7 @@ void ProjectConfigPage::updateCommandLine() } = commandLine.replace(QLatin1String(" -"), QLatin1String("\n-")); - QString filterText =3D ui->commandLineFilter->lineEdit()->text(); + QString filterText =3D ui->commandLineFilter->text(); if (filterText.isEmpty()) { ui->commandLine->setPlainText(commandLine); ui->commandLineBreaks->setEnabled(true); diff --git a/plugins/cppcheck/config/projectconfigpage.ui b/plugins/cppchec= k/config/projectconfigpage.ui index 0724068eec..5b6eebcf69 100644 --- a/plugins/cppcheck/config/projectconfigpage.ui +++ b/plugins/cppcheck/config/projectconfigpage.ui @@ -299,7 +299,14 @@ - + + + Search + + + true + + @@ -345,11 +352,6 @@ - - KFilterProxySearchLine - QWidget -
kfilterproxysearchline.h
-
KMessageWidget QFrame diff --git a/plugins/kdeprovider/CMakeLists.txt b/plugins/kdeprovider/CMake= Lists.txt index f6e6a07a63..72458248f6 100644 --- a/plugins/kdeprovider/CMakeLists.txt +++ b/plugins/kdeprovider/CMakeLists.txt @@ -4,6 +4,7 @@ if(BUILD_TESTING) endif() = set(kdevkdeprovider_PART_SRCS kdeprojectsmodel.cpp + filterproxysearchline.cpp kdeproviderwidget.cpp kdeproviderplugin.cpp kdeprojectsmodel.cpp @@ -13,4 +14,7 @@ kconfig_add_kcfg_files(kdevkdeprovider_PART_SRCS kdeconfi= g.kcfgc) ki18n_wrap_ui(kdevkdeprovider_PART_SRCS kdeconfig.ui) = kdevplatform_add_plugin(kdevkdeprovider JSON kdevkdeprovider.json SOURCES = ${kdevkdeprovider_PART_SRCS}) -target_link_libraries(kdevkdeprovider KF5::ItemViews KDev::Interfaces KDev= ::Vcs) +target_link_libraries(kdevkdeprovider + KDev::Interfaces + KDev::Vcs +) diff --git a/plugins/kdeprovider/filterproxysearchline.cpp b/plugins/kdepro= vider/filterproxysearchline.cpp new file mode 100644 index 0000000000..bb8e4abf94 --- /dev/null +++ b/plugins/kdeprovider/filterproxysearchline.cpp @@ -0,0 +1,58 @@ +/* + * This file is part of KDevelop + * + * Copyright 2018 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "filterproxysearchline.h" + +// KF +#include +// Qt +#include +#include + + +FilterProxySearchLine::FilterProxySearchLine(QWidget *parent) + : QLineEdit(parent) + , m_delayTimer(new QTimer(this)) +{ + setClearButtonEnabled(true); + setPlaceholderText(i18n("Search")); + + m_delayTimer->setSingleShot(true); + m_delayTimer->setInterval(300); + connect(m_delayTimer, &QTimer::timeout, + this, &FilterProxySearchLine::updateFilter); + connect(this, &FilterProxySearchLine::textChanged, + m_delayTimer, static_cast(&QTimer::start)); +} + +void FilterProxySearchLine::setFilterProxyModel(QSortFilterProxyModel* fil= terProxyModel) +{ + m_filterProxyModel =3D filterProxyModel; +} + +void FilterProxySearchLine::updateFilter() +{ + if (!m_filterProxyModel) { + return; + } + + m_filterProxyModel->setFilterFixedString(text()); +} diff --git a/plugins/kdeprovider/kdeproviderwidget.h b/plugins/kdeprovider/= filterproxysearchline.h similarity index 52% copy from plugins/kdeprovider/kdeproviderwidget.h copy to plugins/kdeprovider/filterproxysearchline.h index b7b0d8b2e3..a0507ee4eb 100644 --- a/plugins/kdeprovider/kdeproviderwidget.h +++ b/plugins/kdeprovider/filterproxysearchline.h @@ -1,6 +1,7 @@ /* * This file is part of KDevelop - * Copyright 2010 Aleix Pol Gonzalez + * + * Copyright 2018 Friedrich W. H. Kossebau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -18,29 +19,31 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ = -#ifndef KDEPROVIDERWIDGET_H -#define KDEPROVIDERWIDGET_H +#ifndef KDEPROVIDER_FILTERPROXYSEARCHLINE_H +#define KDEPROVIDER_FILTERPROXYSEARCHLINE_H + +// Qt +#include = -#include +class QTimer; +class QSortFilterProxyModel; = -class QModelIndex; -class KFilterProxySearchLine; -class QListView; -class KDEProviderWidget : public KDevelop::IProjectProviderWidget +class FilterProxySearchLine : public QLineEdit { Q_OBJECT - public: - explicit KDEProviderWidget(QWidget* parent =3D nullptr); - = - KDevelop::VcsJob* createWorkingCopy(const QUrl &destinationDirecto= ry) override; - bool isCorrect() const override; - = - private Q_SLOTS: - void showSettings(); - void projectIndexChanged(const QModelIndex& currentIndex); - = - private: - QListView* m_projects; + +public: + explicit FilterProxySearchLine(QWidget* parent =3D nullptr); + +public: + void setFilterProxyModel(QSortFilterProxyModel* filterProxyModel); + +private: + void updateFilter(); + +private: + QTimer* m_delayTimer; + QSortFilterProxyModel* m_filterProxyModel =3D nullptr; }; = -#endif // KDEPROVIDERWIDGET_H +#endif diff --git a/plugins/kdeprovider/kdeproviderwidget.cpp b/plugins/kdeprovide= r/kdeproviderwidget.cpp index 717bf6cb6f..551229a572 100644 --- a/plugins/kdeprovider/kdeproviderwidget.cpp +++ b/plugins/kdeprovider/kdeproviderwidget.cpp @@ -29,11 +29,12 @@ #include = #include "ui_kdeconfig.h" +#include "filterproxysearchline.h" #include "kdeconfig.h" #include "kdeprojectsmodel.h" #include "kdeprojectsreader.h" #include -#include + #include #include = @@ -45,7 +46,7 @@ KDEProviderWidget::KDEProviderWidget(QWidget* parent) setLayout(new QVBoxLayout); m_projects =3D new QListView(this); QHBoxLayout* topLayout =3D new QHBoxLayout; - KFilterProxySearchLine* filterLine =3D new KFilterProxySearchLine(this= ); + auto filterLine =3D new FilterProxySearchLine(this); KDEProjectsModel* model =3D new KDEProjectsModel(this); KDEProjectsReader* reader =3D new KDEProjectsReader(model, model); connect(reader, &KDEProjectsReader::downloadDone, reader, &KDEProjects= Reader::deleteLater); @@ -68,9 +69,11 @@ KDEProviderWidget::KDEProviderWidget(QWidget* parent) proxyModel->setDynamicSortFilter(true); proxyModel->sort(0); proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + proxyModel->setFilterKeyColumn(-1); + proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_projects->setModel(proxyModel); m_projects->setEditTriggers(QAbstractItemView::NoEditTriggers); - filterLine->setProxy(proxyModel); + filterLine->setFilterProxyModel(proxyModel); } = VcsLocation extractLocation(const QModelIndex& pos) diff --git a/plugins/kdeprovider/kdeproviderwidget.h b/plugins/kdeprovider/= kdeproviderwidget.h index b7b0d8b2e3..7b9ed6bee5 100644 --- a/plugins/kdeprovider/kdeproviderwidget.h +++ b/plugins/kdeprovider/kdeproviderwidget.h @@ -24,8 +24,8 @@ #include = class QModelIndex; -class KFilterProxySearchLine; class QListView; + class KDEProviderWidget : public KDevelop::IProjectProviderWidget { Q_OBJECT