#include "ircchannel.h"
#include "networkinfo.h"
+//#include "nicktreemodel.h"
#include "signalproxy.h"
#include "ircuser.h"
setObjectName(QString::number(networkInfo->networkId()) + "/" + channelname);
}
+IrcChannel::~IrcChannel() {
+
+}
+
// ====================
// PUBLIC:
// ====================
isknown = false;
}
- if(!_userModes.contains(ircuser) && ircuser) {
+ if(!_userModes.contains(ircuser)) {
qWarning() << "Channel" << name() << "received data for unknown User" << ircuser->nick();
isknown = false;
}
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));
}
// ====================
if(!_userModes.contains(ircuser) && ircuser) {
_userModes[ircuser] = QString();
ircuser->joinChannel(name());
- // no emit here since the join is propagated by IrcUser
+ 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
+ emit ircUserJoined(ircuser);
}
}
if(isKnownUser(ircuser)) {
_userModes.remove(ircuser);
ircuser->partChannel(name());
- // no emit here since the part is propagated by IrcUser
+ // 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);
}
}
if(isKnownUser(ircuser)) {
_userModes[ircuser] = modes;
emit userModesSet(ircuser->nick(), modes);
+ emit ircUserModesSet(ircuser, 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);
}
}
addUserMode(networkInfo->ircUser(nick), mode);
}
-
// REMOVE USER MODE
void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode) {
if(!isKnownUser(ircuser) || !isValidChannelUserMode(mode))
if(_userModes[ircuser].contains(mode)) {
_userModes[ircuser].remove(mode);
emit userModeRemoved(ircuser->nick(), mode);
+ emit ircUserModeRemoved(ircuser, mode);
}
}
// INIT SET USER MODES
QVariantMap IrcChannel::initUserModes() const {
QVariantMap usermodes;
- QHashIterator<IrcUser *, QString> iter(_userModes);
- while(iter.hasNext()) {
- iter.next();
+ QHash<IrcUser *, QString>::const_iterator iter = _userModes.constBegin();
+ while(iter != _userModes.constEnd()) {
usermodes[iter.key()->nick()] = iter.value();
+ iter++;
}
return usermodes;
}
}
void IrcChannel::ircUserDestroyed() {
- part(qobject_cast<IrcUser *>(sender()));
+ IrcUser *ircUser = static_cast<IrcUser *>(sender());
+ Q_ASSERT(ircUser);
+ _userModes.remove(ircUser);
+ emit ircUserParted(ircUser);
+}
+
+void IrcChannel::ircUserNickSet(QString nick) {
+ IrcUser *ircUser = qobject_cast<IrcUser *>(sender());
+ Q_ASSERT(ircUser);
+ emit ircUserNickSet(ircUser, nick);
}
void IrcChannel::setInitialized() {