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 {
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<Network *>(sender());
+ Q_ASSERT(net);
+ setCurrentIndex(mapFromSource(Client::networkModel()->networkIndex(net->networkId())));
+ break;
+ default:
+ return;
+ }
+}
+
void BufferModel::synchronizeView(QAbstractItemView *view) {
_selectionModelSynchronizer.synchronizeSelectionModel(view->selectionModel());
}
#include <QSortFilterProxyModel>
#include <QItemSelectionModel>
+#include "network.h"
#include "types.h"
#include "selectionmodelsynchronizer.h"
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;