Browse Source

removed ChatLine vAlignCol

pull/974/head
krepa098 11 years ago
parent
commit
a1cfbeffcb
  1. 9
      src/chatlog/chatline.cpp
  2. 4
      src/chatlog/chatline.h
  3. 12
      src/chatlog/chatlog.cpp

9
src/chatlog/chatline.cpp

@ -155,9 +155,13 @@ void ChatLine::layout(qreal w, QPointF scenePos)
qreal leftover = qMax(0.0, width - fixedWidth); qreal leftover = qMax(0.0, width - fixedWidth);
qreal maxVOffset = 0.0;
qreal xOffset = 0.0; qreal xOffset = 0.0;
for(int i = 0; i < content.size(); ++i) for(int i = 0; i < content.size(); ++i)
{ {
maxVOffset = qMax(maxVOffset, content[i]->firstLineVOffset());
// calculate the effective width of the current column // calculate the effective width of the current column
qreal width; qreal width;
if(format[i].policy == ColumnFormat::FixedSize) if(format[i].policy == ColumnFormat::FixedSize)
@ -193,8 +197,9 @@ void ChatLine::layout(qreal w, QPointF scenePos)
// 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
qreal yOffset = 0.0; qreal yOffset = 0.0;
if(format[i].vAlignCol >= 0 && format[i].vAlignCol < content.size())
yOffset = content[format[i].vAlignCol]->firstLineVOffset() - content[i]->firstLineVOffset(); if(content[i]->firstLineVOffset() > 0.0)
yOffset = maxVOffset - content[i]->firstLineVOffset();
// reposition // reposition
content[i]->setPos(content[i]->pos().x(), content[i]->pos().y() + yOffset); content[i]->setPos(content[i]->pos().x(), content[i]->pos().y() + yOffset);

4
src/chatlog/chatline.h

@ -38,16 +38,14 @@ struct ColumnFormat
}; };
ColumnFormat() {} ColumnFormat() {}
ColumnFormat(qreal s, Policy p, int valign = -1, Align halign = Left) ColumnFormat(qreal s, Policy p, Align halign = Left)
: size(s) : size(s)
, policy(p) , policy(p)
, vAlignCol(valign)
, hAlign(halign) , hAlign(halign)
{} {}
qreal size = 1.0; qreal size = 1.0;
Policy policy = VariableSize; Policy policy = VariableSize;
int vAlignCol = -1;
Align hAlign = Left; Align hAlign = Left;
}; };

12
src/chatlog/chatlog.cpp

@ -76,9 +76,9 @@ ChatLog::~ChatLog()
ChatMessage* ChatLog::addChatMessage(const QString& sender, const QString &msg, bool self) ChatMessage* ChatLog::addChatMessage(const QString& sender, const QString &msg, bool self)
{ {
ChatMessage* line = new ChatMessage(scene, msg); ChatMessage* line = new ChatMessage(scene, msg);
line->addColumn(new Text(sender, self ? Style::getFont(Style::MediumBold) : Style::getFont(Style::Medium), true), ColumnFormat(75.0, ColumnFormat::FixedSize, 1, ColumnFormat::Right)); line->addColumn(new Text(sender, self ? Style::getFont(Style::MediumBold) : Style::getFont(Style::Medium), true), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
line->addColumn(new Text(SmileyPack::getInstance().smileyfied(msg)), ColumnFormat(1.0, ColumnFormat::VariableSize)); line->addColumn(new Text(SmileyPack::getInstance().smileyfied(msg)), ColumnFormat(1.0, ColumnFormat::VariableSize));
line->addColumn(new Spinner(QSizeF(16, 16)), ColumnFormat(50.0, ColumnFormat::FixedSize, 1, ColumnFormat::Right)); line->addColumn(new Spinner(QSizeF(16, 16)), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
insertChatline(line); insertChatline(line);
return line; return line;
@ -95,9 +95,9 @@ ChatMessage* ChatLog::addChatMessage(const QString& sender, const QString& msg,
ChatMessage *ChatLog::addSystemMessage(const QString &msg, const QDateTime& timestamp) ChatMessage *ChatLog::addSystemMessage(const QString &msg, const QDateTime& timestamp)
{ {
ChatMessage* line = new ChatMessage(scene, msg); ChatMessage* line = new ChatMessage(scene, msg);
line->addColumn(new Image(QSizeF(16, 16), ":/ui/chatArea/info.png"), ColumnFormat(75.0, ColumnFormat::FixedSize, 1, ColumnFormat::Right)); line->addColumn(new Image(QSizeF(16, 16), ":/ui/chatArea/info.png"), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
line->addColumn(new Text(msg), ColumnFormat(1.0, ColumnFormat::VariableSize)); line->addColumn(new Text(msg), ColumnFormat(1.0, ColumnFormat::VariableSize));
line->addColumn(new Text(timestamp.toString("hh:mm")), ColumnFormat(50.0, ColumnFormat::FixedSize, 1, ColumnFormat::Right)); line->addColumn(new Text(timestamp.toString("hh:mm")), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
insertChatline(line); insertChatline(line);
return line; return line;
@ -106,9 +106,9 @@ ChatMessage *ChatLog::addSystemMessage(const QString &msg, const QDateTime& time
ChatMessage *ChatLog::addFileTransferMessage(const QString &sender, const ToxFile &file, const QDateTime& timestamp, bool self) ChatMessage *ChatLog::addFileTransferMessage(const QString &sender, const ToxFile &file, const QDateTime& timestamp, bool self)
{ {
ChatMessage* line = new ChatMessage(scene, QString()); ChatMessage* line = new ChatMessage(scene, QString());
line->addColumn(new Text(sender, self ? Style::getFont(Style::MediumBold) : Style::getFont(Style::Medium), true), ColumnFormat(75.0, ColumnFormat::FixedSize, 1, ColumnFormat::Right)); line->addColumn(new Text(sender, self ? Style::getFont(Style::MediumBold) : Style::getFont(Style::Medium), true), ColumnFormat(75.0, ColumnFormat::FixedSize, ColumnFormat::Right));
line->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file)), ColumnFormat(1.0, ColumnFormat::VariableSize)); line->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file)), ColumnFormat(1.0, ColumnFormat::VariableSize));
line->addColumn(new Text(timestamp.toString("hh:mm")), ColumnFormat(50.0, ColumnFormat::FixedSize, 1, ColumnFormat::Right)); line->addColumn(new Text(timestamp.toString("hh:mm")), ColumnFormat(50.0, ColumnFormat::FixedSize, ColumnFormat::Right));
insertChatline(line); insertChatline(line);
return line; return line;

Loading…
Cancel
Save