From: Marcus Eggenberger Date: Tue, 17 Feb 2009 13:20:19 +0000 (+0100) Subject: fixes #543 X-Git-Tag: 0.4.0~15 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=16b0c5bdd6fdaf3e6844ea5ec32e61b20e441284 fixes #543 --- diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index e6bafd70..1a184ab7 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -35,6 +35,7 @@ BufferModel::BufferModel(NetworkModel *parent) connect(_selectionModelSynchronizer.selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(debug_currentChanged(const QModelIndex &, const QModelIndex &))); } + connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(newNetwork(NetworkId))); } bool BufferModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) const { @@ -48,6 +49,29 @@ bool BufferModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) con return false; } +void BufferModel::newNetwork(NetworkId id) { + const Network *net = Client::network(id); + Q_ASSERT(net); + connect(net, SIGNAL(connectionStateSet(Network::ConnectionState)), + this, SLOT(networkConnectionChanged(Network::ConnectionState))); +} + +void BufferModel::networkConnectionChanged(Network::ConnectionState state) { + switch(state) { + case Network::Connecting: + case Network::Initializing: + case Network::Initialized: + if(currentIndex().isValid()) + return; + Network *net = qobject_cast(sender()); + Q_ASSERT(net); + setCurrentIndex(mapFromSource(Client::networkModel()->networkIndex(net->networkId()))); + break; + default: + return; + } +} + void BufferModel::synchronizeView(QAbstractItemView *view) { _selectionModelSynchronizer.synchronizeSelectionModel(view->selectionModel()); } diff --git a/src/client/buffermodel.h b/src/client/buffermodel.h index cb9ffc43..578481b8 100644 --- a/src/client/buffermodel.h +++ b/src/client/buffermodel.h @@ -24,6 +24,7 @@ #include #include +#include "network.h" #include "types.h" #include "selectionmodelsynchronizer.h" @@ -50,9 +51,11 @@ public slots: void setCurrentIndex(const QModelIndex &newCurrent); void switchToBuffer(const BufferId &bufferId); void switchToBufferIndex(const QModelIndex &bufferIdx); - + private slots: void debug_currentChanged(QModelIndex current, QModelIndex previous); + void newNetwork(NetworkId id); + void networkConnectionChanged(Network::ConnectionState state); private: SelectionModelSynchronizer _selectionModelSynchronizer;