X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;h=6dbe17109f9966be9b11ab4debe174c131b96d1b;hp=8207248e2d2a2f6a5d7d1fb1dde03868554bc6f0;hb=bd37d2c94e49e791d2ba44baab4270e030442832;hpb=759834aef5d75034e7092013801d1f957a989b8f diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 8207248e..6dbe1710 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -45,6 +45,7 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, QObject connect(this, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(rectChanged(const QRectF &))); connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(rowsInserted(const QModelIndex &, int, int))); + connect(model, SIGNAL(modelAboutToBeReset()), this, SLOT(modelReset())); for(int i = 0; i < model->rowCount(); i++) { ChatLine *line = new ChatLine(model->index(i, 0)); _lines.append(line); @@ -76,7 +77,6 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, QObject ChatScene::~ChatScene() { - } void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) { @@ -106,6 +106,15 @@ void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) { } } +void ChatScene::modelReset() { + foreach(ChatLine *line, _lines) { + removeItem(line); + delete line; + } + _lines.clear(); + setSceneRect(QRectF(0, 0, _width, 0)); +} + void ChatScene::setWidth(qreal w) { _width = w; _height = 0;