-void BufferWidget::setBuffer(Buffer *buf) {
- /*
- ChatView *chatView;
- if(_chatViews.contains(buf->uid())) {
- chatView = _chatViews[buf->uid()];
+void BufferWidget::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) {
+ Q_ASSERT(model());
+ if(!parent.isValid()) {
+ // ok this means that whole networks are about to be removed
+ // we can't determine which buffers are affect, so we hope that all nets are removed
+ // this is the most common case (for example disconnecting from the core or terminating the clint)
+ if(model()->rowCount(parent) != end - start + 1)
+ return;
+
+ ChatWidget *chatWidget;
+ QHash<BufferId, ChatWidget *>::iterator iter = _chatWidgets.begin();
+ while(iter != _chatWidgets.end()) {
+ chatWidget = *iter;
+ iter = _chatWidgets.erase(iter);
+ ui.stackedWidget->removeWidget(chatWidget);
+ chatWidget->deleteLater();
+ }
+