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("unknown");
42 setFlag(QGraphicsItem::ItemIsFocusable
);
43 setFlag(QGraphicsItem::ItemIsSelectable
);
44 setAcceptHoverEvents(true);
45 resize(ITEM_SIZE
, ITEM_SIZE
);
46 m_bgColor
= QColor(Qt::white
);
47 setToolTip(QString("%1: %2").arg(name
).arg(desc
));
50 MatchItem::~MatchItem()
55 QGraphicsItemAnimation
* MatchItem::anim(bool create
)
59 m_anim
= new QGraphicsItemAnimation();
60 m_anim
->setItem(this);
65 void MatchItem::paint(QPainter
*painter
, const QStyleOptionGraphicsItem
*option
, QWidget
*widget
)
69 painter
->setRenderHint(QPainter::Antialiasing
);
71 if (hasFocus() || isSelected()) {
72 painter
->drawPixmap(0, 0, m_icon
.pixmap(64, 64, QIcon::Active
));
74 painter
->drawPixmap(0, 0, m_icon
.pixmap(64, 64, QIcon::Disabled
));
76 //TODO: Make items glow on hover and draw text over them
79 void MatchItem::mousePressEvent(QGraphicsSceneMouseEvent
*e
)
85 } // namespace QuickSand