Switch some dirty hacking to using real infrastructure. A Chatline now contains three...
[quassel.git] / src / qtui / chatline.cpp
index d4c8390..1abfcfb 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
  *   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 "chatline.h"
-#include "chatlinemodel.h"
 #include "qtui.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);
+
+  _senderItem->setPos(80, 0);
+  _contentsItem->setPos(160, 0);
+}
+
+Chatline::~Chatline() {
 
 }
 
 
 }
 
+QRectF Chatline::boundingRect () const {
+  return childrenBoundingRect();
+}
+
+void Chatline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+
+}
 
 
-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;
+/*
+void ChatLine::setColumnWidths(int tsColWidth, int senderColWidth, int textColWidth) {
+  if(tsColWidth >= 0) {
+    _tsColWidth = tsColWidth;
+    _tsItem->setWidth(tsColWidth);
   }
   }
-  return MessageItem::data(column, role);
+  if(senderColWidth >= 0) {
+    _senderColWidth = senderColWidth;
+    _senderItem->setWidth(senderColWidth);
+  }
+  if(textColWidth >= 0) {
+    _textColWidth = textColWidth;
+    _textItem->setWidth(textColWidth);
+  }
+  layout();
+}
+
+void ChatLine::layout() {
+  prepareGeometryChange();
+  _tsItem->setPos(QPointF(0, 0));
+  _senderItem->setPos(QPointF(_tsColWidth + QtUi::style()->sepTsSender(), 0));
+  _textItem->setPos(QPointF(_tsColWidth + QtUi::style()->sepTsSender() + _senderColWidth + QtUi::style()->sepSenderText(), 0));
 }
 
 }
 
-bool Chatline::setData(int column, const QVariant &value, int role) {
+
+bool ChatLine::sceneEvent ( QEvent * event ) {
+  qDebug() <<(void*)this<< "receiving event";
+  event->ignore();
   return false;
 }
   return false;
 }
+*/
+
+