add a bit of space around each service
[amarok.git] / src / servicebrowser / ServiceListDelegate.cpp
bloba984f1cb07f652f960036add2cce13b6b1e0a324
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();
48 painter->setPen(Qt::gray);
50 painter->setRenderHint ( QPainter::Antialiasing );
53 painter->drawRoundRect( option.rect.topLeft().x() + 2, option.rect.topLeft().y() + 2 ,250,100, 10 ,10 );
55 if (option.state & QStyle::State_Selected)
56 painter->setPen(Qt::blue);
57 else
58 painter->setPen(Qt::black);
60 painter->setFont(QFont("Arial", 16));
62 painter->drawPixmap( option.rect.topLeft() + QPoint( 4, 4 ) , index.data( Qt::DecorationRole ).value<QIcon>().pixmap( 50, 50 ) );
64 painter->drawText( option.rect.topLeft() + QPoint( 55, 35 ) , index.data( Qt::DisplayRole ).toString() );
66 painter->setFont(QFont("Arial", 12));
68 QRectF textRect;
70 textRect.setLeft( option.rect.topLeft().x() + 6 );
71 textRect.setTop( option.rect.topLeft().y() + 48 );
72 textRect.setWidth( 250 );
73 textRect.setHeight( 100 - textRect.top() );
75 painter->drawText ( textRect, Qt::TextWordWrap, index.data( ShortDescriptionRole ).toString() );
78 painter->restore();
82 QSize ServiceListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
84 Q_UNUSED( option );
85 Q_UNUSED( index );
87 DEBUG_BLOCK
89 return QSize ( 252, 102 );