X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fuisupport%2Fabstractbuffercontainer.cpp;h=ad5a281524250f2283f970cd57ecaaed5187e453;hb=HEAD;hp=f6e8de7bae16adb6a21b0e7027a960e3ea4b2cd6;hpb=c194ed5fb3d15e14b9364f9796d3521910dc72fe;p=quassel.git diff --git a/src/uisupport/abstractbuffercontainer.cpp b/src/uisupport/abstractbuffercontainer.cpp index f6e8de7b..ad5a2815 100644 --- a/src/uisupport/abstractbuffercontainer.cpp +++ b/src/uisupport/abstractbuffercontainer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2022 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -19,18 +19,17 @@ ***************************************************************************/ #include "abstractbuffercontainer.h" + #include "client.h" #include "clientbacklogmanager.h" #include "networkmodel.h" -AbstractBufferContainer::AbstractBufferContainer(QWidget *parent) - : AbstractItemView(parent), - _currentBuffer(0) -{ -} +AbstractBufferContainer::AbstractBufferContainer(QWidget* parent) + : AbstractItemView(parent) + , _currentBuffer(0) +{} - -void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) +void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) { Q_ASSERT(model()); if (!parent.isValid()) { @@ -40,15 +39,19 @@ void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex &parent, in if (model()->rowCount(parent) != end - start + 1) return; - foreach(BufferId id, _chatViews.keys()) { + foreach (BufferId id, _chatViews.keys()) { removeChatView(id); } _chatViews.clear(); } else { // check if there are explicitly buffers removed + // Make sure model is valid first + if (!parent.model()) { + return; + } for (int i = start; i <= end; i++) { - QVariant variant = parent.child(i, 0).data(NetworkModel::BufferIdRole); + QVariant variant = parent.model()->index(i, 0, parent).data(NetworkModel::BufferIdRole); if (!variant.isValid()) continue; @@ -58,7 +61,6 @@ void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex &parent, in } } - void AbstractBufferContainer::removeBuffer(BufferId bufferId) { if (!_chatViews.contains(bufferId)) @@ -68,7 +70,6 @@ void AbstractBufferContainer::removeBuffer(BufferId bufferId) _chatViews.take(bufferId); } - /* Switching to first buffer is now handled in MainWin::clientNetworkUpdated() @@ -88,7 +89,7 @@ void AbstractBufferContainer::rowsInserted(const QModelIndex &parent, int start, } */ -void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) +void AbstractBufferContainer::currentChanged(const QModelIndex& current, const QModelIndex& previous) { Q_UNUSED(previous) @@ -101,7 +102,6 @@ void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const Q } } - void AbstractBufferContainer::setCurrentBuffer(BufferId bufferId) { BufferId prevBufferId = currentBuffer();