File indexing completed on 2022-10-04 17:30:16

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2009 Dominik Seichter <domseichter@web.de>
0003 
0004 #include "krenamelistview.h"
0005 
0006 KRenameListView::KRenameListView(QWidget *parent)
0007     : QListView(parent),
0008       m_label(nullptr)
0009 {
0010 }
0011 
0012 void KRenameListView::resizeEvent(QResizeEvent *e)
0013 {
0014     QListView::resizeEvent(e);
0015     positionLabel();
0016 }
0017 
0018 void KRenameListView::slotUpdateCount()
0019 {
0020     this->positionLabel();
0021 }
0022 
0023 void KRenameListView::positionLabel()
0024 {
0025     if (m_label == nullptr) {
0026         return;
0027     }
0028 
0029     if (!this->model() || this->model()->rowCount()) {
0030         m_label->hide();
0031     } else {
0032         int x = (width() - m_label->minimumSizeHint().width()) / 2;
0033         int y = (height() - m_label->minimumSizeHint().height()) / 2;
0034         m_label->setGeometry(x, y,
0035                              m_label->minimumSizeHint().width(), m_label->minimumSizeHint().height());
0036         m_label->show();
0037     }
0038 }