Message flags are now consistently used as Message::Flags rather than quint8.
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 25 Apr 2008 22:11:45 +0000 (22:11 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 25 Apr 2008 22:11:45 +0000 (22:11 +0000)
Also some non-compiling WiP in SPUTDEV.

17 files changed:
src/client/messagemodel.cpp
src/client/messagemodel.h
src/common/message.cpp
src/common/message.h
src/core/basichandler.cpp
src/core/basichandler.h
src/core/coresession.cpp
src/core/coresession.h
src/core/ctcphandler.cpp
src/core/networkconnection.h
src/core/sqlitestorage.cpp
src/core/userinputhandler.cpp
src/qtui/bufferwidget.cpp
src/qtui/chatline.cpp
src/qtui/chatline.h
src/qtui/mainwin.cpp
src/qtui/settingspages/networkssettingspage.ui

index d53449e..4e4b264 100644 (file)
@@ -81,3 +81,28 @@ int MessageModel::indexForId(MsgId id) {
 
 /**********************************************************************************/
 
 
 /**********************************************************************************/
 
+MessageItem::MessageItem(const Message &msg) {
+  _timestamp = msg.timestamp();
+  _msgId = msg.msgId();
+  _bufferId = msg.bufferInfo().bufferId();
+  _type = msg.type();
+  _flags = msg.flags();
+
+}
+
+MessageItem::~MessageItem() {
+
+}
+
+QVariant MessageItem::data(int column, int role) const {
+  if(column < TimestampRole || column > TextRole) return QVariant();
+  switch(role) {
+    case MsgIdRole: return _msgId;
+    case BufferIdRole: return _bufferId;
+    case TypeRole: return _type;
+    case FlagsRole: return _flags;
+    case TimestampRole: return _timestamp;
+    default: return QVariant();
+  }
+}
+
index 1a41f26..336c07e 100644 (file)
 #define MESSAGEMODEL_H_
 
 #include <QAbstractItemModel>
 #define MESSAGEMODEL_H_
 
 #include <QAbstractItemModel>
+#include <QDateTime>
+
+#include "message.h"
+#include "types.h"
 
 
-class Message;
 class MessageItem;
 class MsgId;
 
 class MessageItem;
 class MsgId;
 
@@ -67,15 +70,24 @@ class MessageModel : public QAbstractItemModel {
 };
 
 class MessageItem {
 };
 
 class MessageItem {
-      
+
   public:
   public:
+    enum {
+      TimestampColumn, SenderColumn, TextColumn
+    };
+
     MessageItem(const Message &);
     virtual ~MessageItem();
 
     MessageItem(const Message &);
     virtual ~MessageItem();
 
-
-    virtual QVariant data(int column, int role) const = 0;
+    virtual QVariant data(int column, int role) const;
     virtual bool setData(int column, const QVariant &value, int role) = 0;
 
     virtual bool setData(int column, const QVariant &value, int role) = 0;
 
+  private:
+    QDateTime _timestamp;
+    MsgId _msgId;
+    BufferId _bufferId;
+    Message::Type _type;
+    Message::Flags _flags;
 };
 
 #endif
 };
 
 #endif
index 8c0ebb3..15708b3 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <QDataStream>
 
 
 #include <QDataStream>
 
-Message::Message(BufferInfo bufferInfo, Type type, QString text, QString sender, quint8 flags)
+Message::Message(BufferInfo bufferInfo, Type type, QString text, QString sender, Flags flags)
   : _timestamp(QDateTime::currentDateTime().toUTC()),
     _bufferInfo(bufferInfo),
     _text(text),
   : _timestamp(QDateTime::currentDateTime().toUTC()),
     _bufferInfo(bufferInfo),
     _text(text),
@@ -34,7 +34,7 @@ Message::Message(BufferInfo bufferInfo, Type type, QString text, QString sender,
 {
 }
 
 {
 }
 
-Message::Message(QDateTime ts,BufferInfo bufferInfo, Type type, QString text, QString sender, quint8 flags)
+Message::Message(QDateTime ts,BufferInfo bufferInfo, Type type, QString text, QString sender, Flags flags)
   : _timestamp(ts),
     _bufferInfo(bufferInfo),
     _text(text),
   : _timestamp(ts),
     _bufferInfo(bufferInfo),
     _text(text),
@@ -44,7 +44,7 @@ Message::Message(QDateTime ts,BufferInfo bufferInfo, Type type, QString text, QS
 {
 }
 
 {
 }
 
-void Message::setFlags(quint8 flags) {
+void Message::setFlags(Flags flags) {
   _flags = flags;
 }
 
   _flags = flags;
 }
 
@@ -191,7 +191,7 @@ QDataStream &operator>>(QDataStream &in, Message &msg) {
   BufferInfo buf;
   in >> msg._msgId >> ts >> t >> f >> buf >> s >> m;
   msg._type = (Message::Type)t;
   BufferInfo buf;
   in >> msg._msgId >> ts >> t >> f >> buf >> s >> m;
   msg._type = (Message::Type)t;
-  msg._flags = (quint8)f;
+  msg._flags = (Message::Flags)f;
   msg._bufferInfo = buf;
   msg._timestamp = QDateTime::fromTime_t(ts);
   msg._sender = QString::fromUtf8(s);
   msg._bufferInfo = buf;
   msg._timestamp = QDateTime::fromTime_t(ts);
   msg._sender = QString::fromUtf8(s);
index 08c70c6..9070b05 100644 (file)
@@ -48,18 +48,18 @@ public:
     Error  = 0x1000
   };
 
     Error  = 0x1000
   };
 
-  enum Flags {
+  enum Flag {
     None = 0,
     Self = 1,
     Highlight = 2,
     Redirected = 4
   };
     None = 0,
     Self = 1,
     Highlight = 2,
     Redirected = 4
   };
-  Q_DECLARE_FLAGS(MessageFlags, Flags)
+  Q_DECLARE_FLAGS(Flags, Flag)
   
 
   
 
-  Message(BufferInfo bufferInfo = BufferInfo(), Type type = Plain, QString text = "", QString sender = "", quint8 flags = None);
+  Message(BufferInfo bufferInfo = BufferInfo(), Type type = Plain, QString text = "", QString sender = "", Flags flags = None);
 
 
-  Message(QDateTime ts, BufferInfo buffer = BufferInfo(), Type type = Plain, QString text = "", QString sender = "", quint8 flags = None);
+  Message(QDateTime ts, BufferInfo buffer = BufferInfo(), Type type = Plain, QString text = "", QString sender = "", Flags flags = None);
 
   inline MsgId msgId() const { return _msgId; }
   inline void setMsgId(MsgId id) { _msgId = id; }
 
   inline MsgId msgId() const { return _msgId; }
   inline void setMsgId(MsgId id) { _msgId = id; }
@@ -68,10 +68,10 @@ public:
   inline QString text() const { return _text; }
   inline QString sender() const { return _sender; }
   inline Type type() const { return _type; }
   inline QString text() const { return _text; }
   inline QString sender() const { return _sender; }
   inline Type type() const { return _type; }
-  inline quint8 flags() const { return _flags; }
+  inline Flags flags() const { return _flags; }
   inline QDateTime timestamp() const { return _timestamp; }
 
   inline QDateTime timestamp() const { return _timestamp; }
 
-  void setFlags(quint8 flags);
+  void setFlags(Flags flags);
   
   QString formattedTimestamp();
   QString formattedSender();
   
   QString formattedTimestamp();
   QString formattedSender();
@@ -91,7 +91,7 @@ private:
   QString _text;
   QString _sender;
   Type _type;
   QString _text;
   QString _sender;
   Type _type;
-  quint8 _flags;
+  Flags _flags;
 
   QString _formattedTimestamp, _formattedSender, _formattedText; // cache
 
 
   QString _formattedTimestamp, _formattedSender, _formattedText; // cache
 
@@ -103,6 +103,6 @@ QDataStream &operator<<(QDataStream &out, const Message &msg);
 QDataStream &operator>>(QDataStream &in, Message &msg);
 
 Q_DECLARE_METATYPE(Message);
 QDataStream &operator>>(QDataStream &in, Message &msg);
 
 Q_DECLARE_METATYPE(Message);
-Q_DECLARE_OPERATORS_FOR_FLAGS(Message::MessageFlags)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Message::Flags)
 
 #endif
 
 #endif
index 02483d2..a00966d 100644 (file)
@@ -30,8 +30,8 @@ BasicHandler::BasicHandler(NetworkConnection *parent)
     _networkConnection(parent),
     initDone(false)
 {
     _networkConnection(parent),
     initDone(false)
 {
-  connect(this, SIGNAL(displayMsg(Message::Type, BufferInfo::Type, QString, QString, QString, quint8)),
-         networkConnection(), SIGNAL(displayMsg(Message::Type, BufferInfo::Type, QString, QString, QString, quint8)));
+  connect(this, SIGNAL(displayMsg(Message::Type, BufferInfo::Type, QString, QString, QString, Message::Flags)),
+         networkConnection(), SIGNAL(displayMsg(Message::Type, BufferInfo::Type, QString, QString, QString, Message::Flags)));
 
   connect(this, SIGNAL(putCmd(QString, const QVariantList &, const QByteArray &)),
          networkConnection(), SLOT(putCmd(QString, const QVariantList &, const QByteArray &)));
 
   connect(this, SIGNAL(putCmd(QString, const QVariantList &, const QByteArray &)),
          networkConnection(), SLOT(putCmd(QString, const QVariantList &, const QByteArray &)));
@@ -189,7 +189,7 @@ void BasicHandler::putCmd(const QString &cmd, const QList<QByteArray> &params, c
   emit putCmd(cmd, list, prefix);
 }
 
   emit putCmd(cmd, list, prefix);
 }
 
-void BasicHandler::displayMsg(Message::Type msgType, QString target, QString text, QString sender, quint8 flags) {
+void BasicHandler::displayMsg(Message::Type msgType, QString target, QString text, QString sender, Message::Flags flags) {
   IrcChannel *channel = network()->ircChannel(target);
   if(!channel && (target.startsWith('$') || target.startsWith('#')))
     target = nickFromMask(sender);
   IrcChannel *channel = network()->ircChannel(target);
   if(!channel && (target.startsWith('$') || target.startsWith('#')))
     target = nickFromMask(sender);
index 757af6e..f641a30 100644 (file)
@@ -55,12 +55,12 @@ public:
   QList<QByteArray> userEncode(const QString &userNick, const QStringList &stringlist);
 
 signals:
   QList<QByteArray> userEncode(const QString &userNick, const QStringList &stringlist);
 
 signals:
-  void displayMsg(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
+  void displayMsg(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", Message::Flags flags = Message::None);
   void putCmd(const QString &cmd, const QVariantList &params, const QByteArray &prefix);
   void putRawLine(const QByteArray &msg);
 
 protected:
   void putCmd(const QString &cmd, const QVariantList &params, const QByteArray &prefix);
   void putRawLine(const QByteArray &msg);
 
 protected:
-  void displayMsg(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
+  void displayMsg(Message::Type, QString target, QString text, QString sender = "", Message::Flags flags = Message::None);
   void putCmd(const QString &cmd, const QByteArray &param, const QByteArray &prefix = QByteArray());
   void putCmd(const QString &cmd, const QList<QByteArray> &params, const QByteArray &prefix = QByteArray());
 
   void putCmd(const QString &cmd, const QByteArray &param, const QByteArray &prefix = QByteArray());
   void putCmd(const QString &cmd, const QList<QByteArray> &params, const QByteArray &prefix = QByteArray());
 
index b576854..68f3127 100644 (file)
@@ -192,8 +192,8 @@ void CoreSession::attachNetworkConnection(NetworkConnection *conn) {
   //signalProxy()->attachSignal(conn, SIGNAL(connected(NetworkId)), SIGNAL(networkConnected(NetworkId)));
   //signalProxy()->attachSignal(conn, SIGNAL(disconnected(NetworkId)), SIGNAL(networkDisconnected(NetworkId)));
 
   //signalProxy()->attachSignal(conn, SIGNAL(connected(NetworkId)), SIGNAL(networkConnected(NetworkId)));
   //signalProxy()->attachSignal(conn, SIGNAL(disconnected(NetworkId)), SIGNAL(networkDisconnected(NetworkId)));
 
-  connect(conn, SIGNAL(displayMsg(Message::Type, BufferInfo::Type, QString, QString, QString, quint8)),
-         this, SLOT(recvMessageFromServer(Message::Type, BufferInfo::Type, QString, QString, QString, quint8)));
+  connect(conn, SIGNAL(displayMsg(Message::Type, BufferInfo::Type, QString, QString, QString, Message::Flags)),
+         this, SLOT(recvMessageFromServer(Message::Type, BufferInfo::Type, QString, QString, QString, Message::Flags)));
   connect(conn, SIGNAL(displayStatusMsg(QString)), this, SLOT(recvStatusMsgFromServer(QString)));
 
   connect(conn, SIGNAL(nickChanged(const NetworkId &, const QString &, const QString &)),
   connect(conn, SIGNAL(displayStatusMsg(QString)), this, SLOT(recvStatusMsgFromServer(QString)));
 
   connect(conn, SIGNAL(nickChanged(const NetworkId &, const QString &, const QString &)),
@@ -282,10 +282,11 @@ void CoreSession::msgFromClient(BufferInfo bufinfo, QString msg) {
 
 // ALL messages coming pass through these functions before going to the GUI.
 // So this is the perfect place for storing the backlog and log stuff.
 
 // ALL messages coming pass through these functions before going to the GUI.
 // So this is the perfect place for storing the backlog and log stuff.
-void CoreSession::recvMessageFromServer(Message::Type type, BufferInfo::Type bufferType, QString target, QString text, QString sender, quint8 flags) {
+void CoreSession::recvMessageFromServer(Message::Type type, BufferInfo::Type bufferType,
+                                        QString target, QString text, QString sender, Message::Flags flags) {
   NetworkConnection *netCon = qobject_cast<NetworkConnection*>(this->sender());
   Q_ASSERT(netCon);
   NetworkConnection *netCon = qobject_cast<NetworkConnection*>(this->sender());
   Q_ASSERT(netCon);
-  
+
   BufferInfo bufferInfo = Core::bufferInfo(user(), netCon->networkId(), bufferType, target);
   Message msg(bufferInfo, type, text, sender, flags);
   msg.setMsgId(Core::storeMessage(msg));
   BufferInfo bufferInfo = Core::bufferInfo(user(), netCon->networkId(), bufferType, target);
   Message msg(bufferInfo, type, text, sender, flags);
   msg.setMsgId(Core::storeMessage(msg));
index 482fa76..1403c74 100644 (file)
@@ -153,7 +153,7 @@ private slots:
   void removeClient(QIODevice *dev);
 
   void recvStatusMsgFromServer(QString msg);
   void removeClient(QIODevice *dev);
 
   void recvStatusMsgFromServer(QString msg);
-  void recvMessageFromServer(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
+  void recvMessageFromServer(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", Message::Flags flags = Message::None);
   void networkConnected(NetworkId networkid);
   void networkDisconnected(NetworkId networkid);
 
   void networkConnected(NetworkId networkid);
   void networkDisconnected(NetworkId networkid);
 
index 95fe173..ba48964 100644 (file)
@@ -94,7 +94,7 @@ void CtcpHandler::parse(Message::Type messageType, const QString &prefix, const
     ? CtcpReply
     : CtcpQuery;
   
     ? CtcpReply
     : CtcpQuery;
   
-  quint8 flags = (messageType == Message::Notice && !network()->isChannelName(target))
+  Message::Flags flags = (messageType == Message::Notice && !network()->isChannelName(target))
     ? Message::Redirected
     : Message::None;
 
     ? Message::Redirected
     : Message::None;
 
index 959eb74..0745e9e 100644 (file)
@@ -109,7 +109,7 @@ signals:
   void recvRawServerMsg(QString);
   void displayStatusMsg(QString);
   //void displayMsg(Message msg);
   void recvRawServerMsg(QString);
   void displayStatusMsg(QString);
   //void displayMsg(Message msg);
-  void displayMsg(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
+  void displayMsg(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", Message::Flags flags = Message::None);
   void connected(NetworkId networkId);   ///< Emitted after receipt of 001 to indicate that we can now send data to the IRC server
   void disconnected(NetworkId networkId);
   void connectionStateChanged(Network::ConnectionState);
   void connected(NetworkId networkId);   ///< Emitted after receipt of 001 to indicate that we can now send data to the IRC server
   void disconnected(NetworkId networkId);
   void connectionStateChanged(Network::ConnectionState);
index 8cd4d5b..68120e1 100644 (file)
@@ -629,7 +629,7 @@ MsgId SqliteStorage::logMessage(Message msg) {
   logMessageQuery->bindValue(":time", msg.timestamp().toTime_t());
   logMessageQuery->bindValue(":bufferid", msg.bufferInfo().bufferId().toInt());
   logMessageQuery->bindValue(":type", msg.type());
   logMessageQuery->bindValue(":time", msg.timestamp().toTime_t());
   logMessageQuery->bindValue(":bufferid", msg.bufferInfo().bufferId().toInt());
   logMessageQuery->bindValue(":type", msg.type());
-  logMessageQuery->bindValue(":flags", msg.flags());
+  logMessageQuery->bindValue(":flags", (int)msg.flags());
   logMessageQuery->bindValue(":sender", msg.sender());
   logMessageQuery->bindValue(":message", msg.text());
   logMessageQuery->exec();
   logMessageQuery->bindValue(":sender", msg.sender());
   logMessageQuery->bindValue(":message", msg.text());
   logMessageQuery->exec();
@@ -688,7 +688,7 @@ QList<Message> SqliteStorage::requestMsgs(UserId user, BufferId bufferId, int la
                 (Message::Type)msgQuery->value(2).toUInt(),
                 msgQuery->value(5).toString(),
                 msgQuery->value(4).toString(),
                 (Message::Type)msgQuery->value(2).toUInt(),
                 msgQuery->value(5).toString(),
                 msgQuery->value(4).toString(),
-                msgQuery->value(3).toUInt());
+                (Message::Flags)msgQuery->value(3).toUInt());
     msg.setMsgId(msgQuery->value(0).toInt());
     messagelist << msg;
   }
     msg.setMsgId(msgQuery->value(0).toInt());
     messagelist << msg;
   }
@@ -726,7 +726,7 @@ QList<Message> SqliteStorage::requestMsgs(UserId user, BufferId bufferId, QDateT
                 (Message::Type)msgQuery->value(2).toUInt(),
                 msgQuery->value(5).toString(),
                 msgQuery->value(4).toString(),
                 (Message::Type)msgQuery->value(2).toUInt(),
                 msgQuery->value(5).toString(),
                 msgQuery->value(4).toString(),
-                msgQuery->value(3).toUInt());
+                (Message::Flags)msgQuery->value(3).toUInt());
     msg.setMsgId(msgQuery->value(0).toInt());
     messagelist << msg;
   }
     msg.setMsgId(msgQuery->value(0).toInt());
     messagelist << msg;
   }
@@ -756,7 +756,7 @@ QList<Message> SqliteStorage::requestMsgRange(UserId user, BufferId bufferId, in
                 (Message::Type)rangeQuery->value(2).toUInt(),
                 rangeQuery->value(5).toString(),
                 rangeQuery->value(4).toString(),
                 (Message::Type)rangeQuery->value(2).toUInt(),
                 rangeQuery->value(5).toString(),
                 rangeQuery->value(4).toString(),
-                rangeQuery->value(3).toUInt());
+                (Message::Flags)rangeQuery->value(3).toUInt());
     msg.setMsgId(rangeQuery->value(0).toInt());
     messagelist << msg;
   }
     msg.setMsgId(rangeQuery->value(0).toInt());
     messagelist << msg;
   }
index 0ef5aba..9c7e03b 100644 (file)
@@ -168,6 +168,7 @@ void UserInputHandler::handleKick(const BufferInfo &bufferInfo, const QString &m
 }
 
 void UserInputHandler::handleKill(const BufferInfo &bufferInfo, const QString &msg) {
 }
 
 void UserInputHandler::handleKill(const BufferInfo &bufferInfo, const QString &msg) {
+  Q_UNUSED(bufferInfo)
   QString nick = msg.section(' ', 0, 0, QString::SectionSkipEmpty);
   QString pass = msg.section(' ', 1, -1, QString::SectionSkipEmpty);
   QList<QByteArray> params;
   QString nick = msg.section(' ', 0, 0, QString::SectionSkipEmpty);
   QString pass = msg.section(' ', 1, -1, QString::SectionSkipEmpty);
   QList<QByteArray> params;
@@ -222,6 +223,7 @@ void UserInputHandler::handleOp(const BufferInfo &bufferInfo, const QString &msg
 }
 
 void UserInputHandler::handleOper(const BufferInfo &bufferInfo, const QString &msg) {
 }
 
 void UserInputHandler::handleOper(const BufferInfo &bufferInfo, const QString &msg) {
+  Q_UNUSED(bufferInfo)
   emit putRawLine(serverEncode(QString("OPER %1").arg(msg)));
 }
 
   emit putRawLine(serverEncode(QString("OPER %1").arg(msg)));
 }
 
index c614bb7..0acb5be 100644 (file)
  ***************************************************************************/
 
 #include "bufferwidget.h"
  ***************************************************************************/
 
 #include "bufferwidget.h"
-#include "chatline.h"
-#include "chatline-old.h"
+#ifdef SPUTDEV
+# include "chatline.h"
+#else
+# include "chatline-old.h"
+#endif
 #include "chatview.h"
 #include "chatwidget.h"
 #include "settings.h"
 #include "chatview.h"
 #include "chatwidget.h"
 #include "settings.h"
index 2e659d1..edb89f1 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 "qtui.h"
-
-ChatLine::ChatLine(Message msg) : QGraphicsItem(), AbstractUiMsg() {
-  _styledTimestamp = QtUi::style()->styleString(msg.formattedTimestamp());
-  _styledSender = QtUi::style()->styleString(msg.formattedSender());
-  _styledText = QtUi::style()->styleString(msg.formattedText());
-  _msgId = msg.msgId();
-  _timestamp = msg.timestamp();
-
-  _tsColWidth = _senderColWidth = _textColWidth = 0;
-  QTextOption option;
-  option.setWrapMode(QTextOption::NoWrap);
-  _tsItem = new ChatItem(this);
-  _tsItem->setTextOption(option);
-  _tsItem->setText(_styledTimestamp);
-
-  option.setAlignment(Qt::AlignRight);
-  _senderItem = new ChatItem(this);
-  _senderItem->setTextOption(option);
-  _senderItem->setText(_styledSender);
-
-  option.setAlignment(Qt::AlignLeft);
-  option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
-  _textItem = new ChatItem(this);
-  _textItem->setTextOption(option);
-  _textItem->setText(_styledText);
-
-}
 
 
-ChatLine::~ChatLine() {
-  
-}
-
-QString ChatLine::sender() const {
-  return QString();
-}
-
-QString ChatLine::text() const {
-  return QString();
-}
-
-MsgId ChatLine::msgId() const {
-  return 0;
-}
-
-BufferInfo ChatLine::bufferInfo() const {
-  Q_ASSERT(false); // do we actually need this function???
-  return BufferInfo();
-}
-
-QDateTime ChatLine::timestamp() const {
-  return QDateTime();
-}
-
-QRectF ChatLine::boundingRect () const {
-  return childrenBoundingRect();
-}
-
-void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
-
-}
-
-void ChatLine::setColumnWidths(int tsColWidth, int senderColWidth, int textColWidth) {
-  if(tsColWidth >= 0) {
-    _tsColWidth = tsColWidth;
-    _tsItem->setWidth(tsColWidth);
-  }
-  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));
-}
+Chatline::Chatline(const QMessage &msg) : MessageItem(msg) {
 
 
 
 
-bool ChatLine::sceneEvent ( QEvent * event ) {
-  qDebug() <<(void*)this<< "receiving event";
-  event->ignore();
-  return false;
 }
 
 
 }
 
 
index fca296f..c16de80 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _CHATLINE_H_
-#define _CHATLINE_H_
+#ifndef CHATLINE_H_
+#define CHATLINE_H_
 
 
-#include <QGraphicsItem>
-
-#include "message.h"
-#include "quasselui.h"
-#include "uistyle.h"
-
-class ChatItem;
-class ChatLineData;
-
-/* Concept Ideas
-* Probably makes sense to have ChatLineData be the AbstractUiMsg instead, if it turns out that creating ChatLineData
-is the expensive part... In that case, we could have a QHash<MsgId, ChatLineData*> in the Client, and ChatLine just
-gets a data pointer. This would allow us to share most data between AbstractUiMsgs, and ChatLines themselves could
-be pretty cheap - that'd be a clean solution for having a monitor buffer, highlight buffer etcpp.
-
-* ItemLayoutData
-
-*/
-
-class ChatLine : public QGraphicsItem, public AbstractUiMsg {
-
-  public:
-    ChatLine(Message);
-    virtual ~ChatLine();
-    virtual QString sender() const;
-    virtual QString text() const;
-    virtual MsgId msgId() const;
-    virtual BufferInfo bufferInfo() const;
-    virtual QDateTime timestamp() const;
-
-    virtual QRectF boundingRect () const;
-    virtual void paint (QPainter * painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
-    void layout();
-
-    void setColumnWidths(int tsColWidth, int senderColWidth, int textColWidth);
-
-    void myMousePressEvent ( QGraphicsSceneMouseEvent * event ) { qDebug() << "press"; mousePressEvent(event); }
-
-  protected:
-    bool sceneEvent ( QEvent * event );
-
-  private:
-    UiStyle::StyledText _styledTimestamp, _styledText, _styledSender;
-
-    QDateTime _timestamp;
-    MsgId _msgId;
-
-    ChatItem *_tsItem, *_senderItem, *_textItem;
-    int _tsColWidth, _senderColWidth, _textColWidth;
-};
-
-//! This contains the data of a ChatLine, i.e. mainly the styled message contents.
-/** By separating ChatLine and ChatLineData, ChatLine itself is very small and we can reuse the
- *  same contents in several ChatLine objects without duplicating data.
- */
-class ChatLineData {
+class Chatline : public MessageItem {
 
   public:
 
   public:
-    ChatLineData(const Message &msg);
-
-    inline UiStyle::StyledText styledSender() const { return _styledSender; }
-    inline UiStyle::StyledText styledTimestamp() const { return _styledTimestamp; }
-    inline UiStyle::StyledText styledText() const { return _styledText; }
+    Chatline(const Message &);
 
 
-    inline QString sender() const { return _styledSender.text; }
-    inline QString text() const { return _styledText.text; }
-    inline QDateTime timestamp() const { return _timestamp; }
-    inline MsgId msgId() const { return _msgId; }
-
-  private:
-    UiStyle::StyledText _styledSender, _styledText, _styledTimestamp;
-    QDateTime _timestamp;
-    MsgId _msgId;
+    virtual QVariant data(int column, int role) const;
+    virtual bool setData(int column, const QVariant &value, int role);
 
 };
 
 
 };
 
-
 #endif
 #endif
index 8c77f4c..c0f07a2 100644 (file)
 #include "bufferviewconfig.h"
 #include "bufferviewfilter.h"
 #include "bufferviewmanager.h"
 #include "bufferviewconfig.h"
 #include "bufferviewfilter.h"
 #include "bufferviewmanager.h"
-#include "chatline.h"
-#include "chatline-old.h"
+#ifdef SPUTDEV
+# include "chatline.h"
+#else
+# include "chatline-old.h"
+#endif
 #include "client.h"
 #include "clientbacklogmanager.h"
 #include "coreconnectdlg.h"
 #include "client.h"
 #include "clientbacklogmanager.h"
 #include "coreconnectdlg.h"
index aae2401..7eb6448 100644 (file)
 Unless you *really* know what you do, leave this as ISO-8859-1!</string>
         </property>
         <property name="currentIndex" >
 Unless you *really* know what you do, leave this as ISO-8859-1!</string>
         </property>
         <property name="currentIndex" >
-         <number>1</number>
+         <number>0</number>
         </property>
         <widget class="QWidget" name="serversTab" >
          <property name="enabled" >
         </property>
         <widget class="QWidget" name="serversTab" >
          <property name="enabled" >
@@ -171,8 +171,8 @@ Unless you *really* know what you do, leave this as ISO-8859-1!</string>
           <rect>
            <x>0</x>
            <y>0</y>
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>301</width>
-           <height>326</height>
+           <width>244</width>
+           <height>332</height>
           </rect>
          </property>
          <attribute name="title" >
           </rect>
          </property>
          <attribute name="title" >
@@ -337,8 +337,8 @@ Unless you *really* know what you do, leave this as ISO-8859-1!</string>
           <rect>
            <x>0</x>
            <y>0</y>
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>301</width>
-           <height>326</height>
+           <width>244</width>
+           <height>332</height>
           </rect>
          </property>
          <attribute name="title" >
           </rect>
          </property>
          <attribute name="title" >
@@ -377,13 +377,6 @@ Unless you *really* know what you do, leave this as ISO-8859-1!</string>
              <bool>true</bool>
             </property>
             <layout class="QGridLayout" name="gridLayout" >
              <bool>true</bool>
             </property>
             <layout class="QGridLayout" name="gridLayout" >
-             <item row="0" column="0" >
-              <widget class="QLabel" name="label_2" >
-               <property name="text" >
-                <string>Service:</string>
-               </property>
-              </widget>
-             </item>
              <item row="0" column="1" >
               <widget class="QLineEdit" name="autoIdentifyService" >
                <property name="enabled" >
              <item row="0" column="1" >
               <widget class="QLineEdit" name="autoIdentifyService" >
                <property name="enabled" >
@@ -394,23 +387,30 @@ Unless you *really* know what you do, leave this as ISO-8859-1!</string>
                </property>
               </widget>
              </item>
                </property>
               </widget>
              </item>
-             <item row="1" column="0" >
-              <widget class="QLabel" name="label_3" >
+             <item row="1" column="1" >
+              <widget class="QLineEdit" name="autoIdentifyPassword" >
                <property name="enabled" >
                 <bool>true</bool>
                </property>
                <property name="enabled" >
                 <bool>true</bool>
                </property>
+               <property name="echoMode" >
+                <enum>QLineEdit::Password</enum>
+               </property>
+              </widget>
+             </item>
+             <item row="0" column="0" >
+              <widget class="QLabel" name="label_2" >
                <property name="text" >
                <property name="text" >
-                <string>Password:</string>
+                <string>Service:</string>
                </property>
               </widget>
              </item>
                </property>
               </widget>
              </item>
-             <item row="1" column="1" >
-              <widget class="QLineEdit" name="autoIdentifyPassword" >
+             <item row="1" column="0" >
+              <widget class="QLabel" name="label_3" >
                <property name="enabled" >
                 <bool>true</bool>
                </property>
                <property name="enabled" >
                 <bool>true</bool>
                </property>
-               <property name="echoMode" >
-                <enum>QLineEdit::Password</enum>
+               <property name="text" >
+                <string>Password:</string>
                </property>
               </widget>
              </item>
                </property>
               </widget>
              </item>