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

refactoring

This commit is contained in:
krepa098 2015-02-10 14:30:49 +01:00
parent 990a7f4734
commit 69fde0d8b0
2 changed files with 21 additions and 9 deletions

View File

@ -403,20 +403,34 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
if(newLines.isEmpty())
return;
// move all lines down by n
int n = newLines.size();
for(ChatLine::Ptr l : lines)
l->setRow(l->getRow() + n);
QGraphicsScene::ItemIndexMethod oldIndexMeth = scene->itemIndexMethod();
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
// add the new line
// alloc space for old and new lines
QVector<ChatLine::Ptr> combLines;
combLines.reserve(newLines.size() + lines.size());
// add the new lines
int i = 0;
for(ChatLine::Ptr l : newLines)
{
l->addToScene(scene);
l->setRow(--n);
l->visibilityChanged(false);
lines.prepend(l);
l->setRow(i++);
combLines.push_back(l);
}
// add the old lines
for(ChatLine::Ptr l : lines)
{
l->setRow(i++);
combLines.push_back(l);
}
lines = combLines;
scene->setItemIndexMethod(oldIndexMeth);
// redo layout
startResizeWorker();
}

View File

@ -47,8 +47,6 @@ void Text::setText(const QString& txt)
{
text = txt;
dirty = true;
regenerate();
}
void Text::setWidth(qreal w)