Beispiel #1
0
void FancyItem::setup()
{
	Q3ListView *lv = listView();
	int ph = 0;
	for(int i = 0; i < lv->columns(); ++i) {
		if(pixmap(i))
			ph = QMAX(ph, pixmap(i)->height());
	}
	int y = QMAX(ph, lv->fontMetrics().height());
	y += 8;
	setHeight(y);
}
Beispiel #2
0
void GAlbumViewItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int)
{
    if (!p)
        return;

    Q3ListView *lv = listView();
    if (!lv)
        return;

    QFontMetrics fm(p->fontMetrics());

    if (isSelected())
        p->fillRect(0, 0, width, height(), cg.color(QColorGroup::Highlight));
    else
        p->fillRect(0, 0, width, height(), cg.color(QColorGroup::Base));

    const QPixmap* icon = pixmap(column);

    int iconWidth = 0;
    if (icon)
    {
        iconWidth = icon->width() + lv->itemMargin();
        int xo    = lv->itemMargin();
        int yo    = (height() - icon->height())/2;
        p->drawPixmap( xo, yo, *icon );
    }

    if (isSelected())
        p->setPen( cg.color(QColorGroup::HighlightedText) );
    else
        p->setPen( cg.color(QColorGroup::Text) );

    int r = lv->itemMargin() + iconWidth;
    int h = lv->fontMetrics().height() + 2;
    p->drawText(r, 0, width-r, h, Qt::AlignVCenter, m_album.title);

    QFont fn(lv->font());
    fn.setPointSize(fn.pointSize()-2);
    fn.setItalic(true);
    p->setFont(fn);
    p->setPen(isSelected() ? cg.color(QColorGroup::HighlightedText) : Qt::gray);
    p->drawText(r, h, width-r, h, Qt::AlignVCenter, m_album.name);
}