X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Fircuser.cpp;h=a6146c5bdef14048de2b53df77f70a44daa2ed58;hb=d6b056e936ec441258d291b7a8af7b83f9f53016;hp=bc3414377dfa67f991abd9b0b69fd6be5c4f2f83;hpb=0ff076706c3d353ec9b098b1eca270195288774e;p=quassel.git diff --git a/src/common/ircuser.cpp b/src/common/ircuser.cpp index bc341437..a6146c5b 100644 --- a/src/common/ircuser.cpp +++ b/src/common/ircuser.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel Team * + * Copyright (C) 2005-07 by the Quassel IRC Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -35,10 +35,11 @@ IrcUser::IrcUser(const QString &hostmask, NetworkInfo *networkinfo) _host(hostFromMask(hostmask)), networkInfo(networkinfo) { - setObjectName(QString::number(networkInfo->networkId()) + "/" + IrcUser::hostmask()); + updateObjectName(); } IrcUser::~IrcUser() { + qDebug() << nick() << "destroyed."; } // ==================== @@ -72,11 +73,6 @@ QStringList IrcUser::channels() const { return _channels.toList(); } -void IrcUser::updateObjectName() { - setObjectName(QString::number(networkInfo->networkId()) + "/" + hostmask()); - emit objectNameSet(); -} - // ==================== // PUBLIC SLOTS: // ==================== @@ -84,9 +80,6 @@ void IrcUser::setUser(const QString &user) { if(!user.isEmpty() && _user != user) { _user = user; emit userSet(user); - - setObjectName(hostmask()); - emit objectNameSet(); } } @@ -94,7 +87,6 @@ void IrcUser::setHost(const QString &host) { if(!host.isEmpty() && _host != host) { _host = host; emit hostSet(host); - updateObjectName(); } } @@ -102,35 +94,28 @@ void IrcUser::setNick(const QString &nick) { if(!nick.isEmpty() && nick != _nick) { QString oldnick(_nick); _nick = nick; - emit nickSet(nick); updateObjectName(); + emit nickSet(nick); + } +} + +void IrcUser::updateObjectName() { + QString oldName(objectName()); + setObjectName(QString::number(networkInfo->networkId()) + "/" + _nick); + if(!oldName.isEmpty()) { + emit renameObject(oldName, objectName()); } } + void IrcUser::updateHostmask(const QString &mask) { if(mask == hostmask()) return; QString user = userFromMask(mask); QString host = hostFromMask(mask); - - // we only need to check user and hostmask. - // nick can't have changed since we're identifying IrcUsers by nick - - // we don't use setUser and setHost here. - // though this is unpretty code duplication this saves us one emit objectNameSet() - // the second one would be erroneous - - if(!user.isEmpty() && _user != user) { - _user = user; - } - - if(!host.isEmpty() && _host != host) { - _host = host; - } - - emit hostmaskUpdated(mask); - updateObjectName(); + setUser(user); + setHost(host); } void IrcUser::joinChannel(const QString &channel) {