+ return Client::network(_networkId);
+}
+
+void InputWidget::setNetwork(const Network *network) {
+ if(!network || _networkId == network->networkId())
+ return;
+
+ const Network *previousNet = Client::network(_networkId);
+ if(previousNet) {
+ disconnect(previousNet, 0, this, 0);
+ if(previousNet->me())
+ disconnect(previousNet->me(), 0, this, 0);
+ }
+
+ if(network) {
+ _networkId = network->networkId();
+ connect(network, SIGNAL(identitySet(IdentityId)), this, SLOT(setIdentity(IdentityId)));
+ if(network->me()) {
+ connect(network->me(), SIGNAL(nickSet(QString)), this, SLOT(updateNickSelector()));
+ connect(network->me(), SIGNAL(userModesSet(QString)), this, SLOT(updateNickSelector()));
+ connect(network->me(), SIGNAL(userModesAdded(QString)), this, SLOT(updateNickSelector()));
+ connect(network->me(), SIGNAL(userModesRemoved(QString)), this, SLOT(updateNickSelector()));
+ }
+ }
+ setIdentity(network->identity());
+}
+
+void InputWidget::setIdentity(const IdentityId &identityId) {
+ if(_identityId == identityId)
+ return;
+
+ const Identity *previousIdentity = Client::identity(_identityId);
+ if(previousIdentity)
+ disconnect(previousIdentity, 0, this, 0);
+
+ const Identity *identity = Client::identity(identityId);
+ if(identity) {
+ _identityId = identityId;
+ connect(identity, SIGNAL(nicksSet(QStringList)),
+ this, SLOT(updateNickSelector()));
+ }
+ updateNickSelector();