2
* Copyright (C) 2007-2008 Ryan P. Bitanga <ryan.bitanga@gmail.com>
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.
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.
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 02110-1301 USA .
20
#include <QGraphicsItemAnimation>
26
#include "qs_matchitem.h"
31
MatchItem::MatchItem(const QIcon &icon, const QString &name, const QString &desc, QGraphicsWidget *parent)
32
: QGraphicsWidget(parent),
38
m_icon = KIcon(QLatin1String( "unknown" ));
42
setFlag(QGraphicsItem::ItemIsFocusable);
43
setFlag(QGraphicsItem::ItemIsSelectable);
44
setAcceptHoverEvents(true);
45
resize(ITEM_SIZE, ITEM_SIZE);
46
setToolTip(QString(QLatin1String( "%1: %2" )).arg(name).arg(desc));
49
MatchItem::~MatchItem()
54
QGraphicsItemAnimation* MatchItem::anim(bool create)
58
m_anim = new QGraphicsItemAnimation();
59
m_anim->setItem(this);
64
void MatchItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
68
painter->setRenderHint(QPainter::Antialiasing);
70
if (hasFocus() || isSelected()) {
71
painter->drawPixmap(0, 0, m_icon.pixmap(64, 64, QIcon::Active));
73
painter->drawPixmap(0, 0, m_icon.pixmap(64, 64, QIcon::Disabled));
75
//TODO: Make items glow on hover and draw text over them
78
void MatchItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
84
} // namespace QuickSand