X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fabstractbuffercontainer.cpp;h=4691c9442abdbf65f30bcae615c3961ab02bd1de;hp=8fa435139eeb8dd684a9bbae71e7a123ee1828cd;hb=1477d071abda9697c26ba1c0bbf4c2676faa05a5;hpb=d98055b722222402eaa0543dacd133b9e3eaa52e diff --git a/src/uisupport/abstractbuffercontainer.cpp b/src/uisupport/abstractbuffercontainer.cpp index 8fa43513..4691c944 100644 --- a/src/uisupport/abstractbuffercontainer.cpp +++ b/src/uisupport/abstractbuffercontainer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2010 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -66,10 +66,26 @@ void AbstractBufferContainer::removeBuffer(BufferId bufferId) { _chatViews.take(bufferId); } +void AbstractBufferContainer::rowsInserted(const QModelIndex &parent, int start, int end) { + Q_UNUSED(end) + + if(currentBuffer().isValid()) + return; + + // we want to make sure the very first valid buffer is selected + QModelIndex index = model()->index(start, 0, parent); + if(index.isValid()) { + BufferId id = index.data(NetworkModel::BufferIdRole).value(); + if(id.isValid()) + setCurrentBuffer(id); + } +} + void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { + Q_UNUSED(previous) + BufferId newBufferId = current.data(NetworkModel::BufferIdRole).value(); - BufferId oldBufferId = previous.data(NetworkModel::BufferIdRole).value(); - if(newBufferId != oldBufferId) { + if(newBufferId.isValid() && currentBuffer() != newBufferId) { setCurrentBuffer(newBufferId); emit currentChanged(newBufferId); emit currentChanged(current);