* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include <QDateTime>
+#include <QString>
+#include <QtGui>
+
+#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<UiStyle::FormatList>(_msg.timestamp.formats);
- case ChatlineModel::SenderColumn: return QVariant::fromValue<UiStyle::FormatList>(_msg.sender.formats);
- case ChatlineModel::TextColumn: return QVariant::fromValue<UiStyle::FormatList>(_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) {
+
}