From: Manuel Nickschas Date: Wed, 3 Mar 2010 14:51:34 +0000 (+0100) Subject: Select the first buffer on connect X-Git-Tag: 0.6-rc1~3 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=1477d071abda9697c26ba1c0bbf4c2676faa05a5 Select the first buffer on connect This will show the first valid buffer on connect (usually the status buffer) instead of the giant Quassel logo. Users are confused if they don't see login messages on startup. --- 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); diff --git a/src/uisupport/abstractbuffercontainer.h b/src/uisupport/abstractbuffercontainer.h index 84ab2807..cc77efda 100644 --- a/src/uisupport/abstractbuffercontainer.h +++ b/src/uisupport/abstractbuffercontainer.h @@ -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 * @@ -57,6 +57,7 @@ protected: protected slots: virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); + virtual void rowsInserted(const QModelIndex &parent, int start, int end); //! Show the given chat view /** This method is called when the given chat view should be displayed. Use this e.g. for