File indexing completed on 2024-05-05 04:48:34
0001 /**************************************************************************************** 0002 * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * 0003 * Copyright (c) 2013 Alberto Villa <avilla@FreeBSD.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify it under * 0006 * the terms of the GNU General Public License as published by the Free Software * 0007 * Foundation; either version 2 of the License, or (at your option) any later * 0008 * version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0012 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License along with * 0015 * this program. If not, see <http://www.gnu.org/licenses/>. * 0016 ****************************************************************************************/ 0017 0018 #define DEBUG_PREFIX "MusicBrainzTagsModelDelegate" 0019 0020 #include "MusicBrainzTagsModelDelegate.h" 0021 0022 #include <QApplication> 0023 0024 MusicBrainzTagsModelDelegate::MusicBrainzTagsModelDelegate( QObject *parent ) 0025 : QItemDelegate( parent ) 0026 { 0027 } 0028 0029 void 0030 MusicBrainzTagsModelDelegate::drawCheck( QPainter *painter, 0031 const QStyleOptionViewItem &option, 0032 const QRect &rect, Qt::CheckState state ) const 0033 { 0034 if( !rect.isValid() ) 0035 return; 0036 0037 QStyleOptionViewItem opt( option ); 0038 opt.rect = rect; 0039 opt.state &= ~QStyle::State_HasFocus; 0040 0041 switch( state ) 0042 { 0043 case Qt::Unchecked: 0044 opt.state |= QStyle::State_Off; 0045 break; 0046 case Qt::PartiallyChecked: 0047 opt.state |= QStyle::State_NoChange; 0048 break; 0049 case Qt::Checked: 0050 opt.state |= QStyle::State_On; 0051 break; 0052 } 0053 0054 QApplication::style()->drawPrimitive( QStyle::PE_IndicatorRadioButton, &opt, painter ); 0055 }