}
QVariant MessageModel::data(const QModelIndex &index, int role) const {
- int row = index.row();
- if(row < 0 || row >= _messageList.count()) return QVariant();
+ int row = index.row(); int column = index.column();
+ if(row < 0 || row >= _messageList.count() || column < 0) return QVariant();
+ if(role == ColumnTypeRole) return column;
return _messageList[row]->data(index.column(), role);
}
}
QVariant MessageModelItem::data(int column, int role) const {
- if(column < MessageModel::TimestampColumn || column > MessageModel::TextColumn) return QVariant();
+ if(column < MessageModel::TimestampColumn || column > MessageModel::ContentsColumn) return QVariant();
switch(role) {
case MessageModel::MsgIdRole: return QVariant::fromValue<MsgId>(_msgId);
case MessageModel::BufferIdRole: return QVariant::fromValue<BufferId>(_bufferId);