File indexing completed on 2024-04-21 05:51:43

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2009 Dominik Seichter <domseichter@web.de>
0003 
0004 #ifndef KRENAME_LIST_VIEW_H
0005 #define KRENAME_LIST_VIEW_H
0006 
0007 #include <QListView>
0008 
0009 /**
0010  * This is a QListView implementation
0011  * that shows additional information
0012  * if there are no items in the list
0013  * view.
0014  */
0015 class KRenameListView : public QListView
0016 {
0017     Q_OBJECT
0018 
0019 public:
0020     explicit KRenameListView(QWidget *parent);
0021     ~KRenameListView() override { }
0022 
0023     /**
0024      * Specify the info widget to display
0025      * if the listview contains no items.
0026      *
0027      * The widget will be owned by the KRenameListView.
0028      *
0029      * @param w use widget as info widget
0030      */
0031     inline void setInfoWidget(QWidget *w);
0032 
0033 public Q_SLOTS:
0034     void slotUpdateCount();
0035 
0036 protected:
0037     void resizeEvent(QResizeEvent *e) override;
0038 
0039 private:
0040     /**
0041      * Position the information widget
0042      * and hide/show if necessary.
0043      */
0044     void positionLabel();
0045 
0046 private:
0047     QWidget *m_label; ///< The information widget
0048 };
0049 
0050 inline void KRenameListView::setInfoWidget(QWidget *w)
0051 {
0052     m_label = w;
0053     m_label->setParent(this);
0054     positionLabel();
0055 }
0056 
0057 #endif // KRENAME_LIST_VIEW_H