AlbumShaper 1.0a3
item.cpp
Go to the documentation of this file.
1//==============================================
2// copyright : (C) 2003-2005 by Will Stokes
3//==============================================
4// This program is free software; you can redistribute it
5// and/or modify it under the terms of the GNU General
6// Public License as published by the Free Software
7// Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//==============================================
10
11//Systemwide includes
12#include <qpixmap.h>
13#include <qstring.h>
14#include <qpainter.h>
15#include <q3iconview.h>
16
17//Projectwide includes
18#include "item.h"
19
20//==============================================
21Item::Item( Q3IconView* parent, QPixmap icon, QString text ) : Q3IconViewItem(parent, text, icon)
22{
23 mousedOver = false;
24}
25//==============================================
26void Item::paintItem( QPainter* p, const QColorGroup&)
27{
28 p->save();
29 QRect r = rect();
30
31 //if selected paint dark blue background and outline
32 if(isSelected())
33 {
34 //Draw Selected Color (dark blue)
35 p->fillRect( r, QColor(193, 210, 238) );
36
37 //draw selection rectangle (darker blue)
38 p->setPen( QColor(49, 106, 197) );
39 p->drawRect(r);
40 }
41 //else if pseudo selected paint ligher blue background with outline
42 else if(mousedOver)
43 {
44 //Draw Pseudo Selected Color (light blue)
45 p->fillRect( r, QColor(224, 232, 246) );
46
47 //draw selection rectangle (darker blue)
48 p->setPen( QColor(152, 180, 226) );
49 p->drawRect(r);
50 }
51
52 p->restore();
53
54 p->drawPixmap( x() , y() + ( height() - pixmap()->height() ) / 2, *pixmap());
55
56 int align = Qt::AlignLeft | Qt::TextWordWrap | Qt::TextWrapAnywhere;
57 p->drawText( textRect( FALSE ), align, text());
58}
59//==============================================
60void Item::setMousedOver(bool val)
61{ mousedOver = val; }
62//==============================================
64{
65 QRect pr = pixmapRect();
66 pr.moveBy( 3, 3 );
67 setPixmapRect( pr );
68
69 QRect tr = textRect();
70 tr.moveBy( 3, 3 );
71 tr.setRight( tr.left() + w);
72 setTextRect( tr );
73
74 int newW = pixmapRect().width() + 6 + w;
75 int newH = QMAX( textRect().height(), pixmapRect().height() ) + 6;
76
77 setItemRect( QRect( rect().topLeft(), QSize(newW, newH)) );
78}
79//==============================================
int height
Definition blur.cpp:79
void paintItem(QPainter *p, const QColorGroup &cg)
Definition item.cpp:26
void setMousedOver(bool val)
Definition item.cpp:60
bool mousedOver
Definition item.h:37
Item(Q3IconView *parent, QPixmap icon, QString text)
Definition item.cpp:21
void setTextWidth(int w)
Definition item.cpp:63
QPoint topLeft