#include "floorplanlistdelegate.h"
#include <QtGui>

floorplanlistdelegate::floorplanlistdelegate(QObject *parent) :
    QItemDelegate(parent)
{

}

void floorplanlistdelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
          //if (index.column() == 0) return;
    QStyleOptionViewItemV3 opt = setOptions(index, option);


    // prepare
    painter->save();
    painter->setFont(QFont("MS Shell Dlg 2",6));


    // get the data and the rectangles
    const QPixmap& pixmap
            = qvariant_cast<QPixmap>(index.data(Qt::UserRole+1));

    QRect decorationRect = QRect(opt.rect.topLeft()+QPoint(5,10), pixmap.size());
    decorationRect.moveTo(decorationRect.left(), decorationRect.top());

    const QString& name = index.data(Qt::UserRole).toString();
    QFontMetrics fm(painter->font());
    QRect displayRect = QRect(opt.rect.topLeft()+QPoint(85,15),QSize(180,60));

    const QPixmap& pixmapSmall
            = qvariant_cast<QPixmap>(index.data(Qt::UserRole+2));
    QRect smallIconRect = QRect(opt.rect.topLeft()+QPoint(315,15), pixmapSmall.size());

    drawBackground(painter, opt, index);
    painter->drawPixmap(decorationRect, pixmap);
    painter->drawText(displayRect, name);
    painter->drawPixmap(smallIconRect, pixmapSmall);



    drawFocus(painter, opt, smallIconRect);

    // done
    painter->restore();
}


QSize floorplanlistdelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
    return QSize(300,90);
}
