mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
speed up ChatLine::moveBy
This commit is contained in:
parent
b82c5835ce
commit
0a6bd85308
|
@ -121,13 +121,11 @@ int ChatLine::getColumnCount()
|
||||||
|
|
||||||
void ChatLine::updateBBox()
|
void ChatLine::updateBBox()
|
||||||
{
|
{
|
||||||
bbox = QRectF();
|
bbox.setHeight(0);
|
||||||
bbox.setTop(pos.y());
|
|
||||||
bbox.setLeft(pos.x());
|
|
||||||
bbox.setWidth(width);
|
bbox.setWidth(width);
|
||||||
|
|
||||||
for(ChatLineContent* c : content)
|
for(ChatLineContent* c : content)
|
||||||
bbox.setHeight(qMax(c->sceneBoundingRect().bottom() - pos.y(), bbox.height()));
|
bbox.setHeight(qMax(c->sceneBoundingRect().height(), bbox.height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF ChatLine::boundingSceneRect() const
|
QRectF ChatLine::boundingSceneRect() const
|
||||||
|
@ -157,7 +155,7 @@ void ChatLine::replaceContent(int col, ChatLineContent *lineContent)
|
||||||
if(scene)
|
if(scene)
|
||||||
scene->addItem(content[col]);
|
scene->addItem(content[col]);
|
||||||
|
|
||||||
layout(width, pos);
|
layout(width, bbox.topLeft());
|
||||||
content[col]->visibilityChanged(isVisible);
|
content[col]->visibilityChanged(isVisible);
|
||||||
content[col]->update();
|
content[col]->update();
|
||||||
}
|
}
|
||||||
|
@ -166,7 +164,7 @@ void ChatLine::replaceContent(int col, ChatLineContent *lineContent)
|
||||||
void ChatLine::layout(qreal w, QPointF scenePos)
|
void ChatLine::layout(qreal w, QPointF scenePos)
|
||||||
{
|
{
|
||||||
width = w;
|
width = w;
|
||||||
pos = scenePos;
|
bbox.setTopLeft(scenePos);
|
||||||
|
|
||||||
qreal fixedWidth = (content.size()-1) * CELL_SPACING;
|
qreal fixedWidth = (content.size()-1) * CELL_SPACING;
|
||||||
qreal varWidth = 0.0; // used for normalisation
|
qreal varWidth = 0.0; // used for normalisation
|
||||||
|
@ -217,7 +215,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// reposition
|
// reposition
|
||||||
content[i]->setPos(pos.x() + xOffset + xAlign, pos.y());
|
content[i]->setPos(scenePos.x() + xOffset + xAlign, scenePos.y());
|
||||||
|
|
||||||
xOffset += width + CELL_SPACING;
|
xOffset += width + CELL_SPACING;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +241,5 @@ void ChatLine::moveBy(qreal deltaY)
|
||||||
for(ChatLineContent* c : content)
|
for(ChatLineContent* c : content)
|
||||||
c->moveBy(0, deltaY);
|
c->moveBy(0, deltaY);
|
||||||
|
|
||||||
pos.setY(pos.y() + deltaY);
|
bbox.moveTop(bbox.top() + deltaY);
|
||||||
|
|
||||||
updateBBox();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,6 @@ private:
|
||||||
QVector<ColumnFormat> format;
|
QVector<ColumnFormat> format;
|
||||||
qreal width;
|
qreal width;
|
||||||
QRectF bbox;
|
QRectF bbox;
|
||||||
QPointF pos;
|
|
||||||
bool isVisible = false;
|
bool isVisible = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user