X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fircchannel.cpp;h=47082dd60cf5323f9dc3a9e05c74a232d677d98f;hp=906f4f0ae92e335e99bf1f0756597f12a7e3b4cf;hb=45d9ea6ed5d64eec3ca351fdcf7610c7cff3529d;hpb=7795adca52f35204f8c354da6fcc5d8e8ee35531 diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 906f4f0a..47082dd6 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.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 * @@ -21,6 +21,7 @@ #include "ircchannel.h" #include "networkinfo.h" +//#include "nicktreemodel.h" #include "signalproxy.h" #include "ircuser.h" @@ -48,19 +49,17 @@ IrcChannel::~IrcChannel() { // PUBLIC: // ==================== bool IrcChannel::isKnownUser(IrcUser *ircuser) const { - bool isknown = true; - if(ircuser == 0) { qWarning() << "Channel" << name() << "received IrcUser Nullpointer!"; - isknown = false; + return false; } - if(!_userModes.contains(ircuser) && ircuser) { + if(!_userModes.contains(ircuser)) { qWarning() << "Channel" << name() << "received data for unknown User" << ircuser->nick(); - isknown = false; + return false; } - - return isknown; + + return true; } bool IrcChannel::isValidChannelUserMode(const QString &mode) const { @@ -88,15 +87,15 @@ QList IrcChannel::ircUsers() const { return _userModes.keys(); } -QString IrcChannel::userMode(IrcUser *ircuser) const { +QString IrcChannel::userModes(IrcUser *ircuser) const { if(_userModes.contains(ircuser)) return _userModes[ircuser]; else return QString(); } -QString IrcChannel::userMode(const QString &nick) const { - return userMode(networkInfo->ircUser(nick)); +QString IrcChannel::userModes(const QString &nick) const { + return userModes(networkInfo->ircUser(nick)); } // ==================== @@ -111,6 +110,8 @@ void IrcChannel::join(IrcUser *ircuser) { if(!_userModes.contains(ircuser) && ircuser) { _userModes[ircuser] = QString(); ircuser->joinChannel(name()); + //qDebug() << "JOIN" << name() << ircuser->nick() << ircUsers().count(); + connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString))); connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); // if you wonder why there is no counterpart to ircUserJoined: // the joines are propagted by the ircuser. the signal ircUserJoined is only for convenience @@ -126,6 +127,7 @@ void IrcChannel::part(IrcUser *ircuser) { if(isKnownUser(ircuser)) { _userModes.remove(ircuser); ircuser->partChannel(name()); + //qDebug() << "PART" << name() << ircuser->nick() << ircUsers().count(); // if you wonder why there is no counterpart to ircUserParted: // the joines are propagted by the ircuser. the signal ircUserParted is only for convenience emit ircUserParted(ircuser); @@ -141,6 +143,7 @@ void IrcChannel::setUserModes(IrcUser *ircuser, const QString &modes) { if(isKnownUser(ircuser)) { _userModes[ircuser] = modes; emit userModesSet(ircuser->nick(), modes); + emit ircUserModesSet(ircuser, modes); } } @@ -152,10 +155,11 @@ void IrcChannel::setUserModes(const QString &nick, const QString &modes) { void IrcChannel::addUserMode(IrcUser *ircuser, const QString &mode) { if(!isKnownUser(ircuser) || !isValidChannelUserMode(mode)) return; - + if(!_userModes[ircuser].contains(mode)) { _userModes[ircuser] += mode; emit userModeAdded(ircuser->nick(), mode); + emit ircUserModeAdded(ircuser, mode); } } @@ -164,7 +168,6 @@ void IrcChannel::addUserMode(const QString &nick, const QString &mode) { addUserMode(networkInfo->ircUser(nick), mode); } - // REMOVE USER MODE void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode) { if(!isKnownUser(ircuser) || !isValidChannelUserMode(mode)) @@ -173,6 +176,7 @@ void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode) { if(_userModes[ircuser].contains(mode)) { _userModes[ircuser].remove(mode); emit userModeRemoved(ircuser->nick(), mode); + emit ircUserModeRemoved(ircuser, mode); } } @@ -204,6 +208,14 @@ void IrcChannel::ircUserDestroyed() { IrcUser *ircUser = static_cast(sender()); Q_ASSERT(ircUser); _userModes.remove(ircUser); + emit ircUserParted(ircUser); + //qDebug() << "DEST" << name() << ircUsers().count(); +} + +void IrcChannel::ircUserNickSet(QString nick) { + IrcUser *ircUser = qobject_cast(sender()); + Q_ASSERT(ircUser); + emit ircUserNickSet(ircUser, nick); } void IrcChannel::setInitialized() {