X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=ec45d8739e4ce4708c7817ec71b9daf826b9baec;hp=bec1eb78e08bbdf6eeb6ed5ef14d629060f4ffb6;hb=159fe3f19ba35c482f0a170da50a13b57ea3a5bd;hpb=77176474b628e801ba94d9d50d0d961a12aa01c4 diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index bec1eb78..ec45d873 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -115,11 +115,6 @@ void ChatItem::clearCache() { _cachedLayout = 0; } -void ChatItem::initLayout(QTextLayout *layout, QTextOption::WrapMode mode, Qt::Alignment alignment) const { - initLayoutHelper(layout, mode, alignment); - doLayout(layout); -} - void ChatItem::initLayoutHelper(QTextLayout *layout, QTextOption::WrapMode wrapMode, Qt::Alignment alignment) const { Q_ASSERT(layout); @@ -135,6 +130,11 @@ void ChatItem::initLayoutHelper(QTextLayout *layout, QTextOption::WrapMode wrapM layout->setAdditionalFormats(formatRanges); } +void ChatItem::initLayout(QTextLayout *layout) const { + initLayoutHelper(layout, QTextOption::NoWrap); + doLayout(layout); +} + void ChatItem::doLayout(QTextLayout *layout) const { layout->beginLayout(); QTextLine line = layout->createLine(); @@ -405,6 +405,11 @@ void ChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos) { // SenderChatItem // ************************************************************ +void SenderChatItem::initLayout(QTextLayout *layout) const { + initLayoutHelper(layout, QTextOption::ManualWrap, Qt::AlignRight); + doLayout(layout); +} + void SenderChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); painter->save(); @@ -518,6 +523,11 @@ qreal ContentsChatItem::setGeometryByWidth(qreal w) { return h; } +void ContentsChatItem::initLayout(QTextLayout *layout) const { + initLayoutHelper(layout, QTextOption::WrapAtWordBoundaryOrAnywhere); + doLayout(layout); +} + void ContentsChatItem::doLayout(QTextLayout *layout) const { ChatLineModel::WrapList wrapList = data(ChatLineModel::WrapListRole).value(); if(!wrapList.count()) return; // empty chatitem