Select the first buffer on connect
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 3 Mar 2010 14:51:34 +0000 (15:51 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 3 Mar 2010 14:52:37 +0000 (15:52 +0100)
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.

src/uisupport/abstractbuffercontainer.cpp
src/uisupport/abstractbuffercontainer.h

index 8fa4351..4691c94 100644 (file)
@@ -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<BufferId>();
+    if(id.isValid())
+      setCurrentBuffer(id);
+  }
+}
+
 void AbstractBufferContainer::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
+  Q_UNUSED(previous)
+
   BufferId newBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
-  BufferId oldBufferId = previous.data(NetworkModel::BufferIdRole).value<BufferId>();
-  if(newBufferId != oldBufferId) {
+  if(newBufferId.isValid() && currentBuffer() != newBufferId) {
     setCurrentBuffer(newBufferId);
     emit currentChanged(newBufferId);
     emit currentChanged(current);
index 84ab280..cc77efd 100644 (file)
@@ -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 &current, 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