#include "chatline.h"
#include "qtui.h"
-Chatline::Chatline(const QModelIndex &index, QGraphicsItem *parent) : QGraphicsItem(parent) {
- _timestampItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatlineModel::TimestampColumn)), this);
- _senderItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatlineModel::SenderColumn)), this);
- _contentsItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatlineModel::ContentsColumn)), this);
+ChatLine::ChatLine(const QModelIndex &index, QGraphicsItem *parent) : QGraphicsItem(parent) {
+ _timestampItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::TimestampColumn)), this);
+ _senderItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::SenderColumn)), this);
+ _contentsItem = new ChatItem(QPersistentModelIndex(index.sibling(index.row(), ChatLineModel::ContentsColumn)), this);
_senderItem->setPos(80, 0);
_contentsItem->setPos(160, 0);
}
-Chatline::~Chatline() {
+ChatLine::~ChatLine() {
}
-QRectF Chatline::boundingRect () const {
+QRectF ChatLine::boundingRect () const {
return childrenBoundingRect();
}
-void Chatline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
}
class ChatItem;
-class Chatline : public QGraphicsItem {
+class ChatLine : public QGraphicsItem {
public:
- Chatline(const QModelIndex &tempIndex, QGraphicsItem *parent = 0);
- virtual ~Chatline();
+ ChatLine(const QModelIndex &tempIndex, QGraphicsItem *parent = 0);
+ virtual ~ChatLine();
virtual QRectF boundingRect () const;
virtual void paint (QPainter * painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
#include "chatlinemodelitem.h"
-ChatlineModel::ChatlineModel(QObject *parent) : MessageModel(parent) {
+ChatLineModel::ChatLineModel(QObject *parent) : MessageModel(parent) {
}
-ChatlineModel::~ChatlineModel() {
+ChatLineModel::~ChatLineModel() {
}
-MessageModelItem *ChatlineModel::createMessageModelItem(const Message &msg) {
- return new ChatlineModelItem(msg);
+MessageModelItem *ChatLineModel::createMessageModelItem(const Message &msg) {
+ return new ChatLineModelItem(msg);
}
#include "messagemodel.h"
-class ChatlineModel : public MessageModel {
+class ChatLineModel : public MessageModel {
Q_OBJECT
public:
- enum ChatlineRole {
+ enum ChatLineRole {
FormatRole = MessageModel::UserRole
};
- ChatlineModel(QObject *parent = 0);
- virtual ~ChatlineModel();
+ ChatLineModel(QObject *parent = 0);
+ virtual ~ChatLineModel();
protected:
virtual MessageModelItem *createMessageModelItem(const Message &);
#include "qtui.h"
#include "uistyle.h"
-ChatlineModelItem::ChatlineModelItem(const Message &msg) : MessageModelItem(msg) {
+ChatLineModelItem::ChatLineModelItem(const Message &msg) : MessageModelItem(msg) {
QtUiStyle::StyledMessage m = QtUi::style()->styleMessage(msg);
_timestamp.plainText = m.timestamp.plainText;
}
-QVariant ChatlineModelItem::data(int column, int role) const {
- const ChatlinePart *part;
+QVariant ChatLineModelItem::data(int column, int role) const {
+ const ChatLinePart *part;
switch(column) {
- case ChatlineModel::TimestampColumn: part = &_timestamp; break;
- case ChatlineModel::SenderColumn: part = &_sender; break;
- case ChatlineModel::ContentsColumn: part = &_contents; break;
+ case ChatLineModel::TimestampColumn: part = &_timestamp; break;
+ case ChatLineModel::SenderColumn: part = &_sender; break;
+ case ChatLineModel::ContentsColumn: part = &_contents; break;
default: return MessageModelItem::data(column, role);
}
switch(role) {
- case ChatlineModel::DisplayRole: return part->plainText;
- case ChatlineModel::FormatRole: return QVariant::fromValue<UiStyle::FormatList>(part->formatList);
+ case ChatLineModel::DisplayRole: return part->plainText;
+ case ChatLineModel::FormatRole: return QVariant::fromValue<UiStyle::FormatList>(part->formatList);
}
return MessageModelItem::data(column, role);
}
-bool ChatlineModelItem::setData(int column, const QVariant &value, int role) {
+bool ChatLineModelItem::setData(int column, const QVariant &value, int role) {
return false;
}
#include "messagemodel.h"
#include "uistyle.h"
-class ChatlineModelItem : public MessageModelItem {
+class ChatLineModelItem : public MessageModelItem {
public:
- ChatlineModelItem(const Message &);
- //virtual ~ChatlineModelItem() {};
+ ChatLineModelItem(const Message &);
+ //virtual ~ChatLineModelItem() {};
virtual QVariant data(int column, int role) const;
virtual bool setData(int column, const QVariant &value, int role);
private:
- struct ChatlinePart {
+ struct ChatLinePart {
QString plainText;
UiStyle::FormatList formatList;
};
- ChatlinePart _timestamp, _sender, _contents;
+ ChatLinePart _timestamp, _sender, _contents;
};
#endif
ChatScene::ChatScene(MessageModel *model, QObject *parent) : QGraphicsScene(parent), _model(model) {
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(rowsInserted(const QModelIndex &, int, int)));
for(int i = 0; i < model->rowCount(); i++) {
- Chatline *line = new Chatline(model->index(i, 0));
+ ChatLine *line = new ChatLine(model->index(i, 0));
addItem(line);
line->setPos(30, i*line->boundingRect().height());
}
Q_UNUSED(parent)
return 0;
#else
- return new ChatlineModel(parent);
+ return new ChatLineModel(parent);
#endif
}