modernize: Use 'using' instead of 'typedef'
[quassel.git] / src / qtui / chatlinemodel.h
index 11c9a07..e2fb2df 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -15,7 +15,7 @@
  *   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_
 
 #include "messagemodel.h"
 
-class ChatlineModel : public MessageModel {
-  Q_OBJECT
+#include <QList>
+#include "chatlinemodelitem.h"
 
-  public:
-    enum ChatlineRole {
-      FormatRole = MessageModel::UserRole
+class ChatLineModel : public MessageModel
+{
+    Q_OBJECT
+
+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 &);
 
-  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 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