X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircuser.cpp;h=5f05f0f42a708e9608d0fa4253690853065d3c62;hp=91b3a2b2ea7d16ff8f341bc5699619188cff6691;hb=e733408e4759473bf38831f498f48a0f2f5e6dc7;hpb=e008cd12ef319c4b5f9fe5a8cc1524829551771d diff --git a/src/common/ircuser.cpp b/src/common/ircuser.cpp index 91b3a2b2..5f05f0f4 100644 --- a/src/common/ircuser.cpp +++ b/src/common/ircuser.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -21,20 +21,20 @@ #include "ircuser.h" #include "util.h" -#include "networkinfo.h" +#include "network.h" #include "signalproxy.h" #include "ircchannel.h" #include #include -IrcUser::IrcUser(const QString &hostmask, NetworkInfo *networkinfo) - : QObject(networkinfo), +IrcUser::IrcUser(const QString &hostmask, Network *network) + : SyncableObject(network), _initialized(false), _nick(nickFromMask(hostmask)), _user(userFromMask(hostmask)), _host(hostFromMask(hostmask)), - networkInfo(networkinfo), + _network(network), _codecForEncoding(0), _codecForDecoding(0) { @@ -48,9 +48,6 @@ IrcUser::~IrcUser() { // ==================== // PUBLIC: // ==================== -bool IrcUser::initialized() const { - return _initialized; -} QString IrcUser::user() const { return _user; @@ -81,6 +78,10 @@ QStringList IrcUser::channels() const { return chanList; } +Network* IrcUser::network() const { + return _network; +} + QTextCodec *IrcUser::codecForEncoding() const { return _codecForEncoding; } @@ -106,7 +107,7 @@ void IrcUser::setCodecForDecoding(QTextCodec *codec) { } QString IrcUser::decodeString(const QByteArray &text) const { - if(!codecForDecoding()) return networkInfo->decodeString(text); + if(!codecForDecoding()) return network()->decodeString(text); return ::decodeString(text, codecForDecoding()); } @@ -114,7 +115,7 @@ QByteArray IrcUser::encodeString(const QString string) const { if(codecForEncoding()) { return codecForEncoding()->fromUnicode(string); } - return networkInfo->encodeString(string); + return network()->encodeString(string); } // ==================== @@ -136,7 +137,6 @@ void IrcUser::setHost(const QString &host) { void IrcUser::setNick(const QString &nick) { if(!nick.isEmpty() && nick != _nick) { - QString oldnick(_nick); _nick = nick; updateObjectName(); emit nickSet(nick); @@ -144,14 +144,14 @@ void IrcUser::setNick(const QString &nick) { } void IrcUser::updateObjectName() { - QString oldName(objectName()); - setObjectName(QString::number(networkInfo->networkId()) + "/" + _nick); - if(!oldName.isEmpty()) { - emit renameObject(oldName, objectName()); + QString newName = QString::number(network()->networkId().toInt()) + "/" + _nick; + QString oldName = objectName(); + if(oldName != newName) { + setObjectName(newName); + emit renameObject(oldName, newName); } } - void IrcUser::updateHostmask(const QString &mask) { if(mask == hostmask()) return; @@ -165,15 +165,15 @@ void IrcUser::updateHostmask(const QString &mask) { void IrcUser::joinChannel(IrcChannel *channel) { Q_ASSERT(channel); if(!_channels.contains(channel)) { + _channels.insert(channel); channel->join(this); connect(channel, SIGNAL(destroyed()), this, SLOT(channelDestroyed())); - _channels.insert(channel); emit channelJoined(channel->name()); } } void IrcUser::joinChannel(const QString &channelname) { - joinChannel(networkInfo->newIrcChannel(channelname)); + joinChannel(network()->newIrcChannel(channelname)); } void IrcUser::partChannel(IrcChannel *channel) { @@ -186,7 +186,7 @@ void IrcUser::partChannel(IrcChannel *channel) { } void IrcUser::partChannel(const QString &channelname) { - IrcChannel *channel = networkInfo->ircChannel(channelname); + IrcChannel *channel = network()->ircChannel(channelname); if(channel == 0) { qWarning() << "IrcUser::partChannel(): received part for unknown Channel" << channelname; } else { @@ -229,8 +229,3 @@ void IrcUser::initSetChannels(const QStringList channels) { } } -void IrcUser::setInitialized() { - _initialized = true; - emit initDone(); -} -