forked from blue/squawk
first attempt
This commit is contained in:
parent
8f949277f6
commit
51ac1ac709
5 changed files with 311 additions and 5 deletions
|
@ -42,6 +42,7 @@ MessageDelegate::MessageDelegate(QObject* parent):
|
|||
nickFont(),
|
||||
dateFont(),
|
||||
bodyMetrics(bodyFont),
|
||||
bodyMeter(),
|
||||
nickMetrics(nickFont),
|
||||
dateMetrics(dateFont),
|
||||
buttonHeight(0),
|
||||
|
@ -123,10 +124,7 @@ void MessageDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio
|
|||
opt.displayAlignment = Qt::AlignRight | Qt::AlignTop;
|
||||
}
|
||||
|
||||
QSize bodySize(0, 0);
|
||||
if (data.text.size() > 0) {
|
||||
bodySize = bodyMetrics.boundingRect(opt.rect, Qt::TextWordWrap, data.text).size();
|
||||
}
|
||||
QSize bodySize = bodyMeter.boundingSize(data.text, opt.rect.size());
|
||||
|
||||
QRect rect;
|
||||
if (ntds) {
|
||||
|
@ -306,7 +304,7 @@ QSize MessageDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel
|
|||
Models::FeedItem data = qvariant_cast<Models::FeedItem>(vi);
|
||||
QSize messageSize(0, 0);
|
||||
if (data.text.size() > 0) {
|
||||
messageSize = bodyMetrics.boundingRect(messageRect, Qt::TextWordWrap, data.text).size();
|
||||
messageSize = bodyMeter.boundingSize(data.text, messageRect.size());
|
||||
messageSize.rheight() += textMargin;
|
||||
}
|
||||
|
||||
|
@ -390,9 +388,12 @@ void MessageDelegate::initializeFonts(const QFont& font)
|
|||
dateFont.setPointSize(dateFont.pointSize() * dateFontMultiplier);
|
||||
}
|
||||
|
||||
bodyFont.setKerning(false);
|
||||
bodyMetrics = QFontMetrics(bodyFont);
|
||||
nickMetrics = QFontMetrics(nickFont);
|
||||
dateMetrics = QFontMetrics(dateFont);
|
||||
|
||||
bodyMeter.initializeFonts(bodyFont);
|
||||
|
||||
Preview::initializeFont(bodyFont);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "shared/global.h"
|
||||
#include "shared/utils.h"
|
||||
#include "shared/pathcheck.h"
|
||||
#include "ui/utils/textmeter.h"
|
||||
|
||||
#include "preview.h"
|
||||
|
||||
|
@ -94,6 +95,7 @@ private:
|
|||
QFont nickFont;
|
||||
QFont dateFont;
|
||||
QFontMetrics bodyMetrics;
|
||||
TextMeter bodyMeter;
|
||||
QFontMetrics nickMetrics;
|
||||
QFontMetrics dateMetrics;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue