X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatlinemodel.h;h=ed275d6861f60dcf214a80483cfedb563b072435;hp=4604a9b7559677c4f162614d2076f3263926249b;hb=HEAD;hpb=850f5ae9b96c609f70cdb565bb19054131487714 diff --git a/src/qtui/chatlinemodel.h b/src/qtui/chatlinemodel.h index 4604a9b7..2773be99 100644 --- a/src/qtui/chatlinemodel.h +++ b/src/qtui/chatlinemodel.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-2022 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,41 +15,61 @@ * 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 + +#include "chatlinemodelitem.h" #include "messagemodel.h" -class ChatLineModel : public MessageModel { - Q_OBJECT +class ChatLineModel : public MessageModel +{ + Q_OBJECT public: - enum ChatLineRole { - WrapListRole = MessageModel::UserRole - }; + enum ChatLineRole + { + WrapListRole = MessageModel::UserRole, + MsgLabelRole, + SelectedBackgroundRole + }; - ChatLineModel(QObject *parent = 0); + ChatLineModel(QObject* parent = nullptr); - /// Used to store information about words to be used for wrapping - struct Word { - quint16 start; - qreal width; - qreal trailing; - }; - typedef QVector WrapList; + 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 &); + // 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&) 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 _messageList; }; -QDataStream &operator<<(QDataStream &out, const ChatLineModel::WrapList); -QDataStream &operator>>(QDataStream &in, ChatLineModel::WrapList &); +QDataStream& operator<<(QDataStream& out, const ChatLineModel::WrapList); +QDataStream& operator>>(QDataStream& in, ChatLineModel::WrapList&); Q_DECLARE_METATYPE(ChatLineModel::WrapList) #endif -