/*
    Copyright (C) 2012 Bartosz Broda, Jacek Bochenek, Łukasz Biłeńkij, 
    Damian Jaworski, Wojciech Mazur, Dominik Piasecki, Maciej Piasecki, 
    Radosław Ramocki
    
    This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.

    This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. 

    See the LICENSE and COPYING files for more details.
*/

#include "bubblerect.h"
#include <QPainter>
#include <iostream>

BubbleRect::BubbleRect()
{
    this->text = new QGraphicsTextItem(this);
    this->rectItem = new QGraphicsRectItem(this);
    this->rectItem->setBrush(QBrush(Qt::white));
    this->text->setPos(10, 10);
    this->text->setZValue(30);
    this->rectItem->setPos(5, 5);
    this->rectItem->setZValue(20);
    this->setZValue(50);
}

void BubbleRect::SetText(std::string newText)
{
    QString qstr = QString::fromUtf8(newText.c_str(), newText.length());
    this->text->setHtml(qstr);
    this->rectItem->setRect(0, 0, this->text->boundingRect().width() + 6, this->text->boundingRect().height() + 6);
    this->text->setTextWidth(200);
}

void BubbleRect::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
{

}

QRectF BubbleRect::boundingRect() const
{
    return rectItem->boundingRect();
}
