File indexing completed on 2024-11-24 04:34:19
0001 /*************************************************************************** 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * * 0004 * SPDX-FileCopyrightText: 2004-2023 Thomas Fischer <fischer@unix-ag.uni-kl.de> 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, * 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0014 * GNU General Public License for more details. * 0015 * * 0016 * You should have received a copy of the GNU General Public License * 0017 * along with this program; if not, see <https://www.gnu.org/licenses/>. * 0018 ***************************************************************************/ 0019 0020 #include "filedelegate.h" 0021 0022 #include <KIconLoader> 0023 0024 #include <BibTeXFields> 0025 #include <Entry> 0026 #include <models/FileModel> 0027 #include "widgets/starrating.h" 0028 0029 void FileDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 0030 { 0031 QStyledItemDelegate::paint(painter, option, index); 0032 0033 bool ok = false; 0034 double percent = index.data(FileModel::NumberRole).toDouble(&ok); 0035 if (ok) { 0036 const FieldDescription &fd = BibTeXFields::instance().at(index.column()); 0037 if (fd.upperCamelCase.toLower() == Entry::ftStarRating) { 0038 static StarRatingPainter ratingPainter; 0039 ratingPainter.paint(painter, option.rect, percent); 0040 } 0041 } 0042 }