KItemViews

ktreewidgetsearchlinewidget.cpp
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2003 Scott Wheeler <wheeler@kde.org>
4 SPDX-FileCopyrightText: 2005 Rafal Rzepecki <divide@users.sourceforge.net>
5 SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#include "ktreewidgetsearchlinewidget.h"
11#include "ktreewidgetsearchline.h"
12
13#include <QHBoxLayout>
14#include <QTreeWidget>
15
16class KTreeWidgetSearchLineWidgetPrivate
17{
18public:
19 QTreeWidget *treeWidget = nullptr;
20 KTreeWidgetSearchLine *searchLine = nullptr;
21};
22
24 : QWidget(parent)
25 , d(new KTreeWidgetSearchLineWidgetPrivate)
26{
27 d->treeWidget = treeWidget;
28
29 // can't call createWidgets directly because it calls virtual functions
30 // that might not work if called directly from here due to how inheritance works
31 QMetaObject::invokeMethod(this, "createWidgets", Qt::QueuedConnection);
32}
33
35
40
42{
43 searchLine()->show();
44
45 QHBoxLayout *layout = new QHBoxLayout(this);
46 layout->setContentsMargins(0, 0, 0, 0);
47 layout->addWidget(d->searchLine);
49}
50
52{
53 if (!d->searchLine) {
54 d->searchLine = createSearchLine(d->treeWidget);
55 }
56
57 return d->searchLine;
58}
59
60#include "moc_ktreewidgetsearchlinewidget.cpp"
Creates a widget featuring a KTreeWidgetSearchLine, a label with the text "Search" and a button to cl...
KTreeWidgetSearchLineWidget(QWidget *parent=nullptr, QTreeWidget *treeWidget=nullptr)
Creates a KTreeWidgetSearchLineWidget for treeWidget with parent as the parent.
virtual KTreeWidgetSearchLine * createSearchLine(QTreeWidget *treeWidget) const
Creates the search line.
KTreeWidgetSearchLine * searchLine() const
Returns a pointer to the search line.
virtual void createWidgets()
Creates the widgets inside of the widget.
~KTreeWidgetSearchLineWidget() override
Destroys the KTreeWidgetSearchLineWidget.
This class makes it easy to add a search line for filtering the items in listviews based on a simple ...
void addWidget(QWidget *w)
void setContentsMargins(const QMargins &margins)
bool invokeMethod(QObject *context, Functor &&function, FunctorReturnType *ret)
QueuedConnection
QLayout * layout() const const
void setFocusProxy(QWidget *w)
void show()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.