Less debug noise from ServiceListDelegate
[amarok.git] / src / servicebrowser / ServiceListDelegate.cpp
blobe3549611d42704df281cfbb7ae3f673a01edd875
1 /***************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
20 #include "ServiceListDelegate.h"
22 #include "debug.h"
23 #include "servicebase.h"
24 #include "ServiceListModel.h"
26 #include <QIcon>
27 #include <QPainter>
29 ServiceListDelegate::ServiceListDelegate()
30 : QItemDelegate()
34 ServiceListDelegate::~ServiceListDelegate()
38 void ServiceListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
40 //DEBUG_BLOCK
42 //ServiceBase * service = static_cast< ServiceBase * >( index.internalPointer() );
43 //if ( ! service ) return;
45 debug() << "Look ma' I am painting!";
47 painter->save();
50 painter->setRenderHint ( QPainter::Antialiasing );
53 if (option.state & QStyle::State_Selected)
54 painter->setPen(Qt::blue);
55 else
56 painter->setPen(Qt::gray);
58 painter->drawRoundRect( option.rect.topLeft().x() + 2, option.rect.topLeft().y() + 2 ,250,66, 8 ,8 );
60 if (option.state & QStyle::State_Selected)
61 painter->setPen(Qt::blue);
62 else
63 painter->setPen(Qt::black);
65 painter->setFont(QFont("Arial", 14));
67 painter->drawPixmap( option.rect.topLeft() + QPoint( 4, 4 ) , index.data( Qt::DecorationRole ).value<QIcon>().pixmap( 24, 24 ) );
69 painter->drawText( option.rect.topLeft() + QPoint( 35, 21 ) , index.data( Qt::DisplayRole ).toString() );
71 painter->setFont(QFont("Arial", 10));
73 QRectF textRect;
74 textRect.setLeft( option.rect.topLeft().x() + 6 );
75 textRect.setTop( option.rect.topLeft().y() + 24 );
76 textRect.setWidth( 248 );
77 textRect.setHeight( 40 );
79 painter->drawText ( textRect, Qt::TextWordWrap, index.data( ShortDescriptionRole ).toString() );
81 debug() << "Short description: " << index.data( ShortDescriptionRole ).toString() ;
84 painter->restore();
88 QSize ServiceListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
90 Q_UNUSED( option );
91 Q_UNUSED( index );
93 //DEBUG_BLOCK
95 return QSize ( 252, 70 );