/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel IRC Team *
+ * Copyright (C) 2005-2016 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_
#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 = 0);
+
+ typedef ChatLineModelItem::Word Word;
+ typedef ChatLineModelItem::WrapList WrapList;
+ virtual inline const MessageModelItem *messageItemAt(int i) const { return &_messageList[i]; }
+protected:
+// virtual MessageModelItem *createMessageModelItem(const Message &);
- protected:
- virtual MessageItem *createMessageItem(const Message &);
+ virtual inline int messageCount() const { return _messageList.count(); }
+ virtual inline bool messagesIsEmpty() const { return _messageList.isEmpty(); }
+ virtual inline MessageModelItem *messageItemAt(int i) { return &_messageList[i]; }
+ virtual inline const MessageModelItem *firstMessageItem() const { return &_messageList.first(); }
+ virtual inline MessageModelItem *firstMessageItem() { return &_messageList.first(); }
+ virtual inline const MessageModelItem *lastMessageItem() const { return &_messageList.last(); }
+ virtual inline MessageModelItem *lastMessageItem() { return &_messageList.last(); }
+ virtual inline void insertMessage__(int pos, const Message &msg) { _messageList.insert(pos, ChatLineModelItem(msg)); }
+ virtual void insertMessages__(int pos, const QList<Message> &);
+ virtual inline void removeMessageAt(int i) { _messageList.removeAt(i); }
+ virtual inline void removeAllMessages() { _messageList.clear(); }
+ virtual Message takeMessageAt(int i);
+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