1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(chat): fix type conversion warnings

This commit is contained in:
Nils Fenner 2016-07-11 11:36:08 +02:00
parent b204d0abad
commit b7f65ffe28
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
2 changed files with 15 additions and 15 deletions

View File

@ -176,7 +176,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
qreal fixedWidth = (content.size()-1) * columnSpacing; qreal fixedWidth = (content.size()-1) * columnSpacing;
qreal varWidth = 0.0; // used for normalisation qreal varWidth = 0.0; // used for normalisation
for (size_t i = 0; i < format.size(); ++i) for (int i = 0; i < format.size(); ++i)
{ {
if (format[i].policy == ColumnFormat::FixedSize) if (format[i].policy == ColumnFormat::FixedSize)
fixedWidth += format[i].size; fixedWidth += format[i].size;
@ -191,9 +191,9 @@ void ChatLine::layout(qreal w, QPointF scenePos)
qreal maxVOffset = 0.0; qreal maxVOffset = 0.0;
qreal xOffset = 0.0; qreal xOffset = 0.0;
qreal xPos[content.size()]; QVector<qreal> xPos(content.size());
for (size_t i = 0; i < content.size(); ++i) for (int i = 0; i < content.size(); ++i)
{ {
// calculate the effective width of the current column // calculate the effective width of the current column
qreal width; qreal width;
@ -210,14 +210,14 @@ void ChatLine::layout(qreal w, QPointF scenePos)
switch(format[i].hAlign) switch(format[i].hAlign)
{ {
case ColumnFormat::Left:
break;
case ColumnFormat::Right: case ColumnFormat::Right:
xAlign = width - content[i]->boundingRect().width(); xAlign = width - content[i]->boundingRect().width();
break; break;
case ColumnFormat::Center: case ColumnFormat::Center:
xAlign = (width - content[i]->boundingRect().width()) / 2.0; xAlign = (width - content[i]->boundingRect().width()) / 2.0;
break; break;
default:
break;
} }
// reposition // reposition
@ -227,7 +227,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
maxVOffset = qMax(maxVOffset, content[i]->getAscent()); maxVOffset = qMax(maxVOffset, content[i]->getAscent());
} }
for (size_t i = 0; i < content.size(); ++i) for (int i = 0; i < content.size(); ++i)
{ {
// calculate vertical alignment // calculate vertical alignment
// vertical alignment may depend on width, so we do it in a second pass // vertical alignment may depend on width, so we do it in a second pass

View File

@ -21,9 +21,9 @@
#define CHATLINE_H #define CHATLINE_H
#include <memory> #include <memory>
#include <vector>
#include <QPointF> #include <QPointF>
#include <QRectF> #include <QRectF>
#include <QVector>
class ChatLog; class ChatLog;
class ChatLineContent; class ChatLineContent;
@ -101,8 +101,8 @@ protected:
private: private:
int row = -1; int row = -1;
std::vector<ChatLineContent*> content; QVector<ChatLineContent*> content;
std::vector<ColumnFormat> format; QVector<ColumnFormat> format;
qreal width = 100.0; qreal width = 100.0;
qreal columnSpacing = 15.0; qreal columnSpacing = 15.0;
QRectF bbox; QRectF bbox;