- for(int i = 0; i < modes.count(); i++) {
- if(!_userModes.contains(modes[i]))
- _userModes += modes[i];
- }
+void IrcUser::quitInternal(bool skip_sync)
+{
+ QList<IrcChannel*> channels = _channels.values();
+ _channels.clear();
+ foreach (IrcChannel* channel, channels) {
+ disconnect(channel, nullptr, this, nullptr);
+ channel->part(this);
+ }
+ network()->removeIrcUser(this);
+ if (!skip_sync) SYNC(NO_ARG)
+ emit quited();
+}
+
+void IrcUser::channelDestroyed()
+{
+ // private slot!
+ auto* channel = static_cast<IrcChannel*>(sender());
+ if (_channels.contains(channel)) {
+ _channels.remove(channel);
+ if (_channels.isEmpty() && !network()->isMe(this))
+ quit();
+ }
+}