X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircuser.cpp;h=ed875e030dcb7aac198fca4787fc7565995c4514;hp=99f2ae31d025f7d5b5f94cf6758d42574212fc5b;hb=f66bc9ecb5ebde376da256035db425d7dc0c74d0;hpb=e2e5327ccade6baf433598b1b25dfe99cb360028 diff --git a/src/common/ircuser.cpp b/src/common/ircuser.cpp index 99f2ae31..ed875e03 100644 --- a/src/common/ircuser.cpp +++ b/src/common/ircuser.cpp @@ -28,8 +28,7 @@ #include #include -IrcUser::IrcUser(const QString &hostmask, Network *network) - : SyncableObject(network), +IrcUser::IrcUser(const QString &hostmask, Network *network) : SyncableObject(network), _initialized(false), _nick(nickFromMask(hostmask)), _user(userFromMask(hostmask)), @@ -49,10 +48,6 @@ IrcUser::IrcUser(const QString &hostmask, Network *network) } IrcUser::~IrcUser() { - QList channels = _channels.toList(); - foreach(IrcChannel *channel, channels) { - partChannel(channel); - } } // ==================== @@ -149,7 +144,7 @@ QString IrcUser::decodeString(const QByteArray &text) const { return ::decodeString(text, codecForDecoding()); } -QByteArray IrcUser::encodeString(const QString string) const { +QByteArray IrcUser::encodeString(const QString &string) const { if(codecForEncoding()) { return codecForEncoding()->fromUnicode(string); } @@ -231,12 +226,7 @@ void IrcUser::setNick(const QString &nick) { } void IrcUser::updateObjectName() { - QString newName = QString::number(network()->networkId().toInt()) + "/" + _nick; - QString oldName = objectName(); - if(oldName != newName) { - setObjectName(newName); - emit renameObject(oldName, newName); - } + renameObject(QString::number(network()->networkId().toInt()) + "/" + _nick); } void IrcUser::updateHostmask(const QString &mask) { @@ -253,9 +243,8 @@ void IrcUser::joinChannel(IrcChannel *channel) { Q_ASSERT(channel); if(!_channels.contains(channel)) { _channels.insert(channel); - channel->join(this); + channel->joinIrcUsers(this); connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed())); - emit channelJoined(channel->name()); } } @@ -269,6 +258,8 @@ void IrcUser::partChannel(IrcChannel *channel) { disconnect(channel, 0, this, 0); channel->part(this); emit channelParted(channel->name()); + if(_channels.isEmpty() && network()->isMe(this)) + deleteLater(); } } @@ -284,10 +275,10 @@ void IrcUser::partChannel(const QString &channelname) { void IrcUser::channelDestroyed() { // private slot! IrcChannel *channel = static_cast(sender()); - Q_ASSERT(channel); if(_channels.contains(channel)) { _channels.remove(channel); - disconnect(channel, 0, this, 0); + if(_channels.isEmpty()) + deleteLater(); } } @@ -296,23 +287,24 @@ void IrcUser::setUserModes(const QString &modes) { emit userModesSet(modes); } -void IrcUser::addUserMode(const QString &mode) { - if(!_userModes.contains(mode)) { - _userModes += mode; - emit userModeAdded(mode); - } -} +void IrcUser::addUserModes(const QString &modes) { + if(modes.isEmpty()) + return; -void IrcUser::removeUserMode(const QString &mode) { - if(_userModes.contains(mode)) { - _userModes.remove(mode); - emit userModeRemoved(mode); + for(int i = 0; i < modes.count(); i++) { + if(!_userModes.contains(modes[i])) + _userModes += modes[i]; } + + emit userModesAdded(modes); } -void IrcUser::initSetChannels(const QStringList channels) { - foreach(QString channel, channels) { - joinChannel(channel); +void IrcUser::removeUserModes(const QString &modes) { + if(modes.isEmpty()) + return; + + for(int i = 0; i < modes.count(); i++) { + _userModes.remove(modes[i]); } + emit userModesRemoved(modes); } -