File indexing completed on 2025-04-27 14:34:42
0001 /*************************************************************************** 0002 krenamelistview.cpp - description 0003 ------------------- 0004 begin : Tue Oct 13 2009 0005 copyright : (C) 2009 b Dominik Seichter 0006 email : domseichter@web.de 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #include "krenamelistview.h" 0019 0020 #include <kiconloader.h> 0021 0022 KRenameListView::KRenameListView(QWidget *parent) 0023 : QListView(parent), 0024 m_label(nullptr) 0025 { 0026 } 0027 0028 void KRenameListView::resizeEvent(QResizeEvent *e) 0029 { 0030 QListView::resizeEvent(e); 0031 positionLabel(); 0032 } 0033 0034 void KRenameListView::slotUpdateCount() 0035 { 0036 this->positionLabel(); 0037 } 0038 0039 void KRenameListView::positionLabel() 0040 { 0041 if (m_label == nullptr) { 0042 return; 0043 } 0044 0045 if (!this->model() || this->model()->rowCount()) { 0046 m_label->hide(); 0047 } else { 0048 int x = (width() - m_label->minimumSizeHint().width()) / 2; 0049 int y = (height() - m_label->minimumSizeHint().height()) / 2; 0050 m_label->setGeometry(x, y, 0051 m_label->minimumSizeHint().width(), m_label->minimumSizeHint().height()); 0052 m_label->show(); 0053 } 0054 }