X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatlinemodel.cpp;h=477643c8e580c4f1bb3346f55f66bfd951159198;hp=a1cbbc34cd480e17003ee38b6722e6d676ab19d2;hb=fcacaaf16551524c7ebb6114254d005274cc3d63;hpb=5199330f0b249b20c27cd372d995909f97433786 diff --git a/src/qtui/chatlinemodel.cpp b/src/qtui/chatlinemodel.cpp index a1cbbc34..477643c8 100644 --- a/src/qtui/chatlinemodel.cpp +++ b/src/qtui/chatlinemodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * 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,30 +15,72 @@ * 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. * ***************************************************************************/ #include "chatlinemodel.h" +#include "qtui.h" +#include "qtuistyle.h" ChatLineModel::ChatLineModel(QObject *parent) - : MessageModel(parent) + : MessageModel(parent) { + qRegisterMetaType("ChatLineModel::WrapList"); + qRegisterMetaTypeStreamOperators("ChatLineModel::WrapList"); + connect(QtUi::style(), &UiStyle::changed, this, &ChatLineModel::styleChanged); } + // MessageModelItem *ChatLineModel::createMessageModelItem(const Message &msg) { // return new ChatLineModelItem(msg); // } -void ChatLineModel::insertMessages__(int pos, const QList &messages) { - for(int i = 0; i < messages.count(); i++) { - _messageList.insert(pos, ChatLineModelItem(messages[i])); - pos++; - } +void ChatLineModel::insertMessages__(int pos, const QList &messages) +{ + for (int i = 0; i < messages.count(); i++) { + _messageList.insert(pos, ChatLineModelItem(messages[i])); + pos++; + } +} + + +Message ChatLineModel::takeMessageAt(int i) +{ + Message msg = _messageList[i].message(); + _messageList.removeAt(i); + return msg; +} + + +void ChatLineModel::styleChanged() +{ + foreach(ChatLineModelItem item, _messageList) { + item.invalidateWrapList(); + } + emit dataChanged(index(0, 0), index(rowCount()-1, columnCount()-1)); +} + + +QDataStream &operator<<(QDataStream &out, const ChatLineModel::WrapList wplist) +{ + out << wplist.count(); + ChatLineModel::WrapList::const_iterator it = wplist.begin(); + while (it != wplist.end()) { + out << (*it).start << (*it).width << (*it).trailing; + ++it; + } + return out; } -Message ChatLineModel::takeMessageAt(int i) { - Message msg = _messageList[i].message(); - _messageList.removeAt(i); - return msg; + +QDataStream &operator>>(QDataStream &in, ChatLineModel::WrapList &wplist) +{ + quint16 cnt; + in >> cnt; + wplist.resize(cnt); + for (quint16 i = 0; i < cnt; i++) { + in >> wplist[i].start >> wplist[i].width >> wplist[i].trailing; + } + return in; }