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);
ChatScene::~ChatScene() {
-
}
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;