1 /***************************************************************************
2 * Copyright (C) 2005-2010 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "qmlchatline.h"
22 #include "qmlmessagemodel.h"
23 #include "qmlmessagemodelitem.h"
26 QmlMessageModelItem::QmlMessageModelItem(const Message &msg)
30 if(!msg.sender().contains('!'))
31 _styledMsg.setFlags(msg.flags() |= Message::ServerMsg);
34 QVariant QmlMessageModelItem::data(int column, int role) const {
37 case QmlMessageModel::ChatLineDataRole: {
38 QmlChatLine::Data data;
39 data.timestamp.text = _styledMsg.decoratedTimestamp();
40 data.timestamp.formats = UiStyle::FormatList() << qMakePair((quint16)0, (quint32)UiStyle::formatType(_styledMsg.type()) | UiStyle::Timestamp);
41 data.sender.text = _styledMsg.decoratedSender();
42 data.sender.formats = UiStyle::FormatList() << qMakePair((quint16)0, (quint32)UiStyle::formatType(_styledMsg.type()) | UiStyle::Sender);
43 data.contents.text = _styledMsg.plainContents();
44 data.contents.formats = _styledMsg.contentsFormatList();
45 return QVariant::fromValue<QmlChatLine::Data>(data);
50 if(!variant.isValid())
51 return MessageModelItem::data(column, role);