X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fbuffermodel.cpp;h=1ae0c2e9d15878fa5871d168703e0ba87da9862e;hp=328cede2591dba541d2f53f857ca873449d8d210;hb=3474e986630907fa2a3f4143012ac2a42796609e;hpb=ab3dc87d0c27026f5da0a27fd1f6b980c8a7ef98 diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index 328cede2..1ae0c2e9 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -60,7 +60,6 @@ void BufferModel::networkConnectionChanged(Network::ConnectionState state) { switch(state) { case Network::Connecting: case Network::Initializing: - case Network::Initialized: if(currentIndex().isValid()) return; { @@ -103,6 +102,17 @@ void BufferModel::switchToBufferIndex(const QModelIndex &bufferIdx) { qWarning() << "BufferModel::switchToBufferIndex(const QModelIndex &):" << bufferIdx << "does not belong to BufferModel or NetworkModel"; } +void BufferModel::switchToOrJoinBuffer(NetworkId networkId, const QString &name) { + BufferId bufId = Client::networkModel()->bufferId(networkId, name); + if(bufId.isValid()) { + QModelIndex targetIdx = Client::networkModel()->bufferIndex(bufId); + switchToBuffer(bufId); + if(!targetIdx.data(NetworkModel::ItemActiveRole).toBool()) + Client::userInput(BufferInfo::fakeStatusBuffer(networkId), QString("/JOIN %1").arg(name)); + } else + Client::userInput(BufferInfo::fakeStatusBuffer(networkId), QString("/JOIN %1").arg(name)); +} + void BufferModel::debug_currentChanged(QModelIndex current, QModelIndex previous) { Q_UNUSED(previous); qDebug() << "Switched current Buffer: " << current << current.data().toString() << "Buffer:" << current.data(NetworkModel::BufferIdRole).value();