diff --git a/plugins/clazy/config/commandlinewidget.cpp b/plugins/clazy/config/commandlinewidget.cpp --- a/plugins/clazy/config/commandlinewidget.cpp +++ b/plugins/clazy/config/commandlinewidget.cpp @@ -34,7 +34,7 @@ m_ui->setupUi(this); m_ui->cmdEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); - connect(m_ui->cmdFilter->lineEdit(), &QLineEdit::textChanged, this, &CommandLineWidget::updateCommandLine); + connect(m_ui->cmdFilter, &QLineEdit::textChanged, this, &CommandLineWidget::updateCommandLine); connect(m_ui->cmdBreak, &QCheckBox::stateChanged, this, &CommandLineWidget::updateCommandLine); } @@ -56,7 +56,7 @@ commandLine.replace(QLatin1String(","), QLatin1String("\n,")); } - auto filterText = m_ui->cmdFilter->lineEdit()->text(); + auto filterText = m_ui->cmdFilter->text(); if (!filterText.isEmpty()) { QStringList lines = commandLine.split(QLatin1Char('\n')); QMutableStringListIterator i(lines); diff --git a/plugins/clazy/config/commandlinewidget.ui b/plugins/clazy/config/commandlinewidget.ui --- 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 --- a/plugins/cppcheck/CMakeLists.txt +++ b/plugins/cppcheck/CMakeLists.txt @@ -52,7 +52,6 @@ ) 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/cppcheck/config/projectconfigpage.cpp --- a/plugins/cppcheck/config/projectconfigpage.cpp +++ b/plugins/cppcheck/config/projectconfigpage.cpp @@ -43,7 +43,7 @@ ui->commandLine->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); connect(this, &ProjectConfigPage::changed, this, &ProjectConfigPage::updateCommandLine); - connect(ui->commandLineFilter->lineEdit(), &QLineEdit::textChanged, this, &ProjectConfigPage::updateCommandLine); + connect(ui->commandLineFilter, &QLineEdit::textChanged, this, &ProjectConfigPage::updateCommandLine); connect(ui->commandLineBreaks, &QCheckBox::stateChanged, this, &ProjectConfigPage::updateCommandLine); } @@ -105,7 +105,7 @@ } commandLine.replace(QLatin1String(" -"), QLatin1String("\n-")); - QString filterText = ui->commandLineFilter->lineEdit()->text(); + QString filterText = ui->commandLineFilter->text(); if (filterText.isEmpty()) { ui->commandLine->setPlainText(commandLine); ui->commandLineBreaks->setEnabled(true); diff --git a/plugins/cppcheck/config/projectconfigpage.ui b/plugins/cppcheck/config/projectconfigpage.ui --- 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/CMakeLists.txt --- a/plugins/kdeprovider/CMakeLists.txt +++ b/plugins/kdeprovider/CMakeLists.txt @@ -4,6 +4,7 @@ endif() set(kdevkdeprovider_PART_SRCS kdeprojectsmodel.cpp + filterproxysearchline.cpp kdeproviderwidget.cpp kdeproviderplugin.cpp kdeprojectsmodel.cpp @@ -13,4 +14,7 @@ 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/kdeproviderwidget.h b/plugins/kdeprovider/filterproxysearchline.h copy from plugins/kdeprovider/kdeproviderwidget.h copy to plugins/kdeprovider/filterproxysearchline.h --- 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 = nullptr); - - KDevelop::VcsJob* createWorkingCopy(const QUrl &destinationDirectory) override; - bool isCorrect() const override; - - private Q_SLOTS: - void showSettings(); - void projectIndexChanged(const QModelIndex& currentIndex); - - private: - QListView* m_projects; + +public: + explicit FilterProxySearchLine(QWidget* parent = nullptr); + +public: + void setFilterProxyModel(QSortFilterProxyModel* filterProxyModel); + +private: + void updateFilter(); + +private: + QTimer* m_delayTimer; + QSortFilterProxyModel* m_filterProxyModel = nullptr; }; -#endif // KDEPROVIDERWIDGET_H +#endif diff --git a/plugins/kdeprovider/filterproxysearchline.cpp b/plugins/kdeprovider/filterproxysearchline.cpp new file mode 100644 --- /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* filterProxyModel) +{ + m_filterProxyModel = filterProxyModel; +} + +void FilterProxySearchLine::updateFilter() +{ + if (!m_filterProxyModel) { + return; + } + + m_filterProxyModel->setFilterFixedString(text()); +} diff --git a/plugins/kdeprovider/kdeproviderwidget.h b/plugins/kdeprovider/kdeproviderwidget.h --- 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 diff --git a/plugins/kdeprovider/kdeproviderwidget.cpp b/plugins/kdeprovider/kdeproviderwidget.cpp --- 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 @@ setLayout(new QVBoxLayout); m_projects = new QListView(this); QHBoxLayout* topLayout = new QHBoxLayout; - KFilterProxySearchLine* filterLine = new KFilterProxySearchLine(this); + auto filterLine = new FilterProxySearchLine(this); KDEProjectsModel* model = new KDEProjectsModel(this); KDEProjectsReader* reader = new KDEProjectsReader(model, model); connect(reader, &KDEProjectsReader::downloadDone, reader, &KDEProjectsReader::deleteLater); @@ -68,9 +69,11 @@ 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)