2 * SomePlayer - An alternate music player for Maemo 5
3 * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "trackrenderer.h"
22 #include <QFontMetrics>
26 TrackRenderer::TrackRenderer(QObject *parent) :
27 QAbstractItemDelegate(parent)
31 void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
32 QString value = index.data().toString();
33 QStringList meta = value.split("#_#");
35 QFont f = painter->font();
36 QFont fp = painter->font();
39 option.rect.getCoords(&x1, &y1, &x2, &y2);
41 QPen pen = painter->pen();
42 QPen npen (QColor::fromRgb(80, 130, 255, 50));
43 QPen apen (QColor::fromRgb(255, 255, 255, 128));
44 QPen spen (QColor::fromRgb(100, 150, 220));
45 QPen sspen (QColor::fromRgb(100, 220, 150));
50 painter->setPen(npen);
51 painter->drawLine(x1, y1, x2, y1);
52 if (index.row() == _search_row) {
53 painter->setPen(sspen);
54 } else if (index.row() == _active_row) {
55 painter->setPen(spen);
59 painter->drawText(x1, y1 + 2*(y2-y1)/5, meta[0]);
61 fp.setPointSize(f.pointSize()*3/4);
63 painter->setPen(apen);
64 painter->drawText((x2+x1)/2, y1 + 4*(y2-y1)/6, meta[1]);
65 painter->drawText((x2+x1)/2, y1 + 11*(y2-y1)/12, meta[2]);
66 painter->setPen(npen);
67 painter->drawLine(x1, y2, x2, y2);
72 QSize TrackRenderer::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const {
73 return QSize(option.rect.width(), 80);
76 void TrackRenderer::setActiveRow(int r) {
80 void TrackRenderer::setSearchRow(int r) {