layout->setTextOption(option);
QList<QTextLayout::FormatRange> formatRanges
- = QtUi::style()->toTextLayoutList(data(MessageModel::FormatRole).value<UiStyle::FormatList>(), layout->text().length());
+ = QtUi::style()->toTextLayoutList(data(MessageModel::FormatRole).value<UiStyle::FormatList>(), layout->text().length(), data(ChatLineModel::MsgLabelRole).toUInt());
layout->setAdditionalFormats(formatRanges);
}
void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
Q_UNUSED(option); Q_UNUSED(widget);
painter->setClipRect(boundingRect()); // no idea why QGraphicsItem clipping won't work
+
+ QVariant bgBrush = data(ChatLineModel::BackgroundRole);
+ if(bgBrush.isValid())
+ painter->fillRect(boundingRect(), bgBrush.value<QBrush>());
+
QVector<QTextLayout::FormatRange> formats = additionalFormats();
QTextLayout::FormatRange selectFmt = selectionFormat();
if(selectFmt.format.isValid()) formats.append(selectFmt);
Q_UNUSED(option); Q_UNUSED(widget);
painter->setClipRect(boundingRect()); // no idea why QGraphicsItem clipping won't work
+
+ QVariant bgBrush = data(ChatLineModel::BackgroundRole);
+ if(bgBrush.isValid())
+ painter->fillRect(boundingRect(), bgBrush.value<QBrush>());
+
QTextLayout layout;
initLayout(&layout);
qreal layoutWidth = layout.minimumWidth();
: ChatItem(0, 0, pos, parent),
_data(0)
{
- const QAbstractItemModel *model_ = model();
- QModelIndex index = model_->index(row(), column());
- _fontMetrics = QtUi::style()->fontMetrics(model_->data(index, ChatLineModel::FormatRole).value<UiStyle::FormatList>().at(0).second);
-
setGeometryByWidth(width);
}
+QFontMetricsF *ContentsChatItem::fontMetrics() const {
+ return QtUi::style()->fontMetrics(data(ChatLineModel::FormatRole).value<UiStyle::FormatList>().at(0).second);
+}
+
ContentsChatItem::~ContentsChatItem() {
delete _data;
}
QList<ContentsChatItem::Clickable> ContentsChatItem::findClickables() const {
// For matching URLs
static QString urlEnd("(?:>|[,.;:\"]*\\s|\\b|$)");
- static QString urlChars("(?:[,.;:]*[\\w\\-~@/?&=+$()!%#*|{}\\[\\]'])");
+ static QString urlChars("(?:[,.;:]*[\\w\\-~@/?&=+$()!%#*|{}\\[\\]'^])");
static QRegExp regExp[] = {
// URL
// QRegExp(QString("((?:https?://|s?ftp://|irc://|mailto:|www\\.)%1+|%1+\\.[a-z]{2,4}(?:?=/%1+|\\b))%2").arg(urlChars, urlEnd)),
- QRegExp(QString("((?:(?:https?://|s?ftp://|irc://|gopher://|mailto:)|www)%1+)%2").arg(urlChars, urlEnd), Qt::CaseInsensitive),
+ QRegExp(QString("((?:(?:mailto:|\\w+://)|www\\.)%1+)%2").arg(urlChars, urlEnd), Qt::CaseInsensitive),
// Channel name
// We don't match for channel names starting with + or &, because that gives us a lot of false positives.