X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fbuffermodel.cpp;h=328cede2591dba541d2f53f857ca873449d8d210;hp=e6bafd7098d84828de0a4d337f609093c6e1e9d7;hb=ab3dc87d0c27026f5da0a27fd1f6b980c8a7ef98;hpb=f824db0e31b54969e0b7fa0b5405b1e9173d482c diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index e6bafd70..328cede2 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,31 @@ 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()); }