qa: Replace deprecated qVariantFromValue() by QVariant::fromValue()
[quassel.git] / src / qtui / chatlinemodel.h
index b61bd66..2d07a88 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   Copyright (C) 2005-2019 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
 #ifndef CHATLINEMODEL_H_
 #define CHATLINEMODEL_H_
 
+#include <QList>
+
+#include "chatlinemodelitem.h"
 #include "messagemodel.h"
 
-class ChatLineModel : public MessageModel {
-  Q_OBJECT
+class ChatLineModel : public MessageModel
+{
+    Q_OBJECT
 
-  public:
-    enum ChatLineRole {
-      FormatRole = MessageModel::UserRole
+public:
+    enum ChatLineRole
+    {
+        WrapListRole = MessageModel::UserRole,
+        MsgLabelRole,
+        SelectedBackgroundRole
     };
 
-    ChatLineModel(QObject *parent = 0);
-    virtual ~ChatLineModel();
+    ChatLineModel(QObject* parent = nullptr);
+
+    using Word = ChatLineModelItem::Word;
+    using WrapList = ChatLineModelItem::WrapList;
+    inline const MessageModelItem* messageItemAt(int i) const override { return &_messageList[i]; }
+
+protected:
+    //   virtual MessageModelItem *createMessageModelItem(const Message &);
+
+    inline int messageCount() const override { return _messageList.count(); }
+    inline bool messagesIsEmpty() const override { return _messageList.isEmpty(); }
+    inline MessageModelItem* messageItemAt(int i) override { return &_messageList[i]; }
+    inline const MessageModelItem* firstMessageItem() const override { return &_messageList.first(); }
+    inline MessageModelItem* firstMessageItem() override { return &_messageList.first(); }
+    inline const MessageModelItem* lastMessageItem() const override { return &_messageList.last(); }
+    inline MessageModelItem* lastMessageItem() override { return &_messageList.last(); }
+    inline void insertMessage__(int pos, const Message& msg) override { _messageList.insert(pos, ChatLineModelItem(msg)); }
+    void insertMessages__(int pos, const QList<Message>&) override;
+    inline void removeMessageAt(int i) override { _messageList.removeAt(i); }
+    inline void removeAllMessages() override { _messageList.clear(); }
+    Message takeMessageAt(int i) override;
 
-  protected:
-    virtual MessageModelItem *createMessageModelItem(const Message &);
+protected slots:
+    virtual void styleChanged();
 
+private:
+    QList<ChatLineModelItem> _messageList;
 };
 
-#endif
+QDataStream& operator<<(QDataStream& out, const ChatLineModel::WrapList);
+QDataStream& operator>>(QDataStream& in, ChatLineModel::WrapList&);
+
+Q_DECLARE_METATYPE(ChatLineModel::WrapList)
 
+#endif