00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <qpixmap.h>
00013 #include <qstring.h>
00014 #include <qpainter.h>
00015 #include <qiconview.h>
00016
00017
00018 #include "groupIcon.h"
00019 #include "groupsWidget.h"
00020
00021
00022 GroupIcon::GroupIcon( QIconView* parent, QPixmap icon,
00023 QString text, QWidget* settingsWidget) :
00024 QIconViewItem(parent, text, icon)
00025 {
00026 this->parent = parent;
00027 this->settingsWidget = settingsWidget;
00028 mousedOver = false;
00029
00030
00031 initializeItemRect();
00032 }
00033
00034 void GroupIcon::paintItem( QPainter* p, const QColorGroup&)
00035 {
00036 p->save();
00037 QRect r = rect();
00038
00039
00040 if(isSelected())
00041 {
00042
00043 p->fillRect( r, QColor(193, 210, 238) );
00044
00045
00046 p->setPen( QColor(49, 106, 197) );
00047 p->drawRect(r);
00048 }
00049
00050 else if(mousedOver)
00051 {
00052
00053 p->fillRect( r, QColor(224, 232, 246) );
00054
00055
00056 p->setPen( QColor(152, 180, 226) );
00057 p->drawRect(r);
00058 }
00059
00060 p->restore();
00061
00062 p->drawPixmap( x()+3 , y() + ( height() - pixmap()->height() ) / 2, *pixmap());
00063
00064 int align = AlignLeft | WordBreak | BreakAnywhere;
00065 p->drawText( textRect( FALSE ), align, text());
00066 }
00067
00068 void GroupIcon::paintFocus( QPainter*, const QColorGroup&) { }
00069
00070 QWidget* GroupIcon::getSettingsWidget() { return settingsWidget; }
00071
00072 void GroupIcon::setMousedOver(bool val) { mousedOver = val; }
00073
00074 void GroupIcon::initializeItemRect()
00075 {
00076
00077 QRect pr = pixmapRect();
00078 int prWidth = pr.width();
00079 int prHeight = pr.height();
00080 pr.setTopLeft( QPoint(3,3) );
00081 pr.setBottomRight( QPoint(pr.left()+prWidth, pr.top()+prHeight) );
00082 setPixmapRect( pr );
00083
00084
00085 int textWidth = ((GroupsWidget*)parent)->getTextWidth();
00086 QRect tr = textRect();
00087 tr.setTop( pixmapRect().top() );
00088 tr.setBottom( pixmapRect().bottom() );
00089 tr.setLeft( pixmapRect().right() + 2 );
00090 tr.setRight( tr.left() + textWidth );
00091 setTextRect( tr );
00092
00093
00094 int itemW = 3 + pixmapRect().width() + (tr.left() - pr.right()) + textRect().width() + 3;
00095 int itemH = 3 + pixmapRect().height() + 3;
00096 setItemRect( QRect( pixmapRect().left() - 3, pixmapRect().top() - 3, itemW, itemH ) );
00097 }
00098