Some cosmetic corrections and some minor work on the nick model. Hopefully I
[quassel.git] / src / common / ircchannel.cpp
index 29b618f..412ad2a 100644 (file)
@@ -21,6 +21,7 @@
 #include "ircchannel.h"
 
 #include "networkinfo.h"
+//#include "nicktreemodel.h"
 #include "signalproxy.h"
 #include "ircuser.h"
 
@@ -40,6 +41,10 @@ IrcChannel::IrcChannel(const QString &channelname, NetworkInfo *networkinfo)
   setObjectName(QString::number(networkInfo->networkId()) + "/" +  channelname);
 }
 
+IrcChannel::~IrcChannel() {
+
+}
+
 // ====================
 //  PUBLIC:
 // ====================
@@ -107,8 +112,11 @@ void IrcChannel::join(IrcUser *ircuser) {
   if(!_userModes.contains(ircuser) && ircuser) {
     _userModes[ircuser] = QString();
     ircuser->joinChannel(name());
+    connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString)));
     connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed()));
-    // no emit here since the join is propagated by IrcUser
+    // 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);
   }
 }
 
@@ -120,7 +128,9 @@ void IrcChannel::part(IrcUser *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);
   }
 }
 
@@ -133,6 +143,7 @@ void IrcChannel::setUserModes(IrcUser *ircuser, const QString &modes) {
   if(isKnownUser(ircuser)) {
     _userModes[ircuser] = modes;
     emit userModesSet(ircuser->nick(), modes);
+    emit userModesSet(ircuser, modes);
   }
 }
 
@@ -148,6 +159,7 @@ void IrcChannel::addUserMode(IrcUser *ircuser, const QString &mode) {
   if(!_userModes[ircuser].contains(mode)) {
     _userModes[ircuser] += mode;
     emit userModeAdded(ircuser->nick(), mode);
+    emit userModeAdded(ircuser, mode);
   }
 
 }
@@ -156,15 +168,15 @@ 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) {
+void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode) { qDebug() << "remove mode:" << ircuser->nick() << mode;
   if(!isKnownUser(ircuser) || !isValidChannelUserMode(mode))
     return;
 
   if(_userModes[ircuser].contains(mode)) {
     _userModes[ircuser].remove(mode);
     emit userModeRemoved(ircuser->nick(), mode);
+    emit userModeRemoved(ircuser, mode);
   }
 
 }
@@ -198,6 +210,12 @@ void IrcChannel::ircUserDestroyed() {
   _userModes.remove(ircUser);
 }
 
+void IrcChannel::ircUserNickSet(QString nick) {
+  IrcUser *ircUser = qobject_cast<IrcUser *>(sender());
+  Q_ASSERT(ircUser);
+  emit ircUserNickSet(ircUser, nick);
+}
+
 void IrcChannel::setInitialized() {
   _initialized = true;
   emit initDone();