+void BufferModel::switchToBufferIndex(const QModelIndex &bufferIdx) {
+ // we accept indexes that directly belong to us or our parent - nothing else
+ if(bufferIdx.model() == this) {
+ setCurrentIndex(bufferIdx);
+ return;
+ }
+
+ if(bufferIdx.model() == sourceModel()) {
+ setCurrentIndex(mapFromSource(bufferIdx));
+ return;
+ }
+
+ 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));
+}
+