X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=237fad68fbae63aaca7570a1caebeae046f14676;hp=d4c83909ffd10077707a7d227635df01870a096b;hb=39e2a78383295f86c5aa2dadbeac6f02b53eb7a4;hpb=858cba7fac9928549219de070397be65e1b92cde diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index d4c83909..237fad68 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -18,37 +18,51 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include +#include +#include + +#include "bufferinfo.h" +#include "chatitem.h" #include "chatline.h" -#include "chatlinemodel.h" #include "qtui.h" -#include "uistyle.h" -Chatline::Chatline(const Message &msg) : MessageItem(msg) { - _msg = QtUi::style()->styleMessage(msg); +ChatLine::ChatLine(const QModelIndex &index, QGraphicsItem *parent) : QGraphicsItem(parent) { + _timestampItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::TimestampColumn)), this); + _senderItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::SenderColumn)), this); + _contentsItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::ContentsColumn)), this); + + _timestampItem->setPos(0,0); + _width = _height = 0; +} + +ChatLine::~ChatLine() { + delete _timestampItem; + delete _senderItem; + delete _contentsItem; +} +QRectF ChatLine::boundingRect () const { + //return childrenBoundingRect(); + return QRectF(0, 0, _width, _height); } +qreal ChatLine::setGeometry(qreal width, qreal firstHandlePos, qreal secondHandlePos) { + if(width != _width) prepareGeometryChange(); + qreal firstsep = QtUi::style()->firstColumnSeparator()/2; + qreal secondsep = QtUi::style()->secondColumnSeparator()/2; + + _timestampItem->setWidth(firstHandlePos - firstsep); + _senderItem->setWidth(secondHandlePos - firstHandlePos - (firstsep+secondsep)); + _height = _contentsItem->setWidth(width - secondHandlePos - secondsep); -QVariant Chatline::data(int column, int role) const { - switch(role) { - case ChatlineModel::DisplayRole: - switch(column) { - case ChatlineModel::TimestampColumn: return _msg.timestamp.text; - case ChatlineModel::SenderColumn: return _msg.sender.text; - case ChatlineModel::TextColumn: return _msg.text.text; - } - break; - case ChatlineModel::FormatRole: - switch(column) { - case ChatlineModel::TimestampColumn: return QVariant::fromValue(_msg.timestamp.formats); - case ChatlineModel::SenderColumn: return QVariant::fromValue(_msg.sender.formats); - case ChatlineModel::TextColumn: return QVariant::fromValue(_msg.text.formats); - } - break; - } - return MessageItem::data(column, role); + _senderItem->setPos(firstHandlePos + firstsep, 0); + _contentsItem->setPos(secondHandlePos + secondsep, 0); + + _width = width; + return _height; } -bool Chatline::setData(int column, const QVariant &value, int role) { - return false; +void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + }