File indexing completed on 2024-07-14 03:54:54

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2003 Scott Wheeler <wheeler@kde.org>
0004     SPDX-FileCopyrightText: 2005 Rafal Rzepecki <divide@users.sourceforge.net>
0005     SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-only
0008 */
0009 
0010 #ifndef KTREEWIDGETSEARCHLINEWIDGET_H
0011 #define KTREEWIDGETSEARCHLINEWIDGET_H
0012 
0013 #include <QWidget>
0014 #include <kitemviews_export.h>
0015 #include <memory>
0016 
0017 class QModelIndex;
0018 class QTreeWidget;
0019 class KTreeWidgetSearchLine;
0020 
0021 /**
0022  * @class KTreeWidgetSearchLineWidget ktreewidgetsearchlinewidget.h KTreeWidgetSearchLineWidget
0023  *
0024  * Creates a widget featuring a KTreeWidgetSearchLine, a label with the text
0025  * "Search" and a button to clear the search.
0026  */
0027 class KITEMVIEWS_EXPORT KTreeWidgetSearchLineWidget : public QWidget
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     /**
0033      * Creates a KTreeWidgetSearchLineWidget for \a treeWidget with \a parent as the
0034      * parent.
0035      */
0036     explicit KTreeWidgetSearchLineWidget(QWidget *parent = nullptr, QTreeWidget *treeWidget = nullptr);
0037 
0038     /**
0039      * Destroys the KTreeWidgetSearchLineWidget
0040      */
0041     ~KTreeWidgetSearchLineWidget() override;
0042 
0043     /**
0044      * Returns a pointer to the search line.
0045      */
0046     KTreeWidgetSearchLine *searchLine() const;
0047 
0048 protected Q_SLOTS:
0049     /**
0050      * Creates the widgets inside of the widget.  This is called from the
0051      * constructor via a single shot timer so that it it guaranteed to run
0052      * after construction is complete.  This makes it suitable for overriding in
0053      * subclasses.
0054      */
0055     virtual void createWidgets();
0056 
0057 protected:
0058     /**
0059      * Creates the search line.  This can be useful to reimplement in cases where
0060      * a KTreeWidgetSearchLine subclass is used.
0061      *
0062      * It is const because it is be called from searchLine(), which to the user
0063      * doesn't conceptually alter the widget.
0064      */
0065     virtual KTreeWidgetSearchLine *createSearchLine(QTreeWidget *treeWidget) const;
0066 
0067 private:
0068     std::unique_ptr<class KTreeWidgetSearchLineWidgetPrivate> const d;
0069 };
0070 
0071 #endif