users who are away are now greyed out in the nickview
[quassel.git] / src / client / networkmodel.cpp
index 04ade52..7cfc5f6 100644 (file)
@@ -143,6 +143,13 @@ void BufferItem::attachIrcChannel(IrcChannel *ircChannel) {
          this, SLOT(userModeChanged(IrcUser *)));
   connect(ircChannel, SIGNAL(ircUserModeRemoved(IrcUser *, QString)),
          this, SLOT(userModeChanged(IrcUser *)));
+
+  if(!ircChannel->ircUsers().isEmpty()) {
+    qWarning() << "Channel" << ircChannel->name() << "has already users which is quite surprising :)";
+    foreach(IrcUser *ircUser, ircChannel->ircUsers()) {
+      join(ircUser);
+    }
+  }
   
   emit dataChanged();
 }
@@ -229,6 +236,7 @@ void BufferItem::removeUserFromCategory(IrcUser *ircUser) {
 
   
   if(!success) {
+    qDebug() << "didn't find User:" << ircUser << (quint64)ircUser;
     qDebug() << "==== Childlist for Item:" << this << id() << bufferName() << "====";
     for(int i = 0; i < childCount(); i++) {
       categoryItem = qobject_cast<UserCategoryItem *>(child(i));
@@ -283,8 +291,16 @@ quint64 NetworkItem::id() const {
   return _networkId.toInt();
 }
 
+void NetworkItem::setActive(bool connected) {
+  Q_UNUSED(connected);
+  emit dataChanged();
+}
+
 bool NetworkItem::isActive() const {
-  return _network;
+  if(_network)
+    return _network->isConnected();
+  else
+    return false;
 }
 
 QString NetworkItem::networkName() const {
@@ -320,6 +336,9 @@ void NetworkItem::attachNetwork(Network *network) {
          this, SLOT(setCurrentServer(QString)));
   connect(network, SIGNAL(ircChannelAdded(QString)),
          this, SLOT(attachIrcChannel(QString)));
+  connect(network, SIGNAL(connectedSet(bool)),
+         this, SLOT(setActive(bool)));
+  
   // FIXME: connect this and that...
 
   emit dataChanged();
@@ -396,6 +415,8 @@ int UserCategoryItem::categoryFromModes(const QString &modes) {
 
 QVariant UserCategoryItem::data(int column, int role) const {
   switch(role) {
+  case NetworkModel::ItemActiveRole:
+    return true;
   case NetworkModel::ItemTypeRole:
     return NetworkModel::UserCategoryItemType;
   case NetworkModel::BufferIdRole:
@@ -438,6 +459,8 @@ quint64 IrcUserItem::id() const {
 
 QVariant IrcUserItem::data(int column, int role) const {
   switch(role) {
+  case NetworkModel::ItemActiveRole:
+    return !_ircUser->isAway();
   case NetworkModel::ItemTypeRole:
     return NetworkModel::IrcUserItemType;
   case NetworkModel::BufferIdRole:
@@ -453,7 +476,14 @@ QVariant IrcUserItem::data(int column, int role) const {
 
 QString IrcUserItem::toolTip(int column) const {
   Q_UNUSED(column);
-  return "<p><b>" + nickName() + "</b><br />" + _ircUser->hostmask() + "</p>";
+  QString toolTip = "<b>" + nickName() + "</b><br />" + _ircUser->hostmask();
+  if(_ircUser->isAway()) {
+    toolTip += "<br /> away";
+    if(!_ircUser->awayMessage().isEmpty()) { 
+      toolTip += " (" + _ircUser->awayMessage() + ")"; 
+    }
+  }
+  return "<p>" + toolTip + "</p>";
 }
 
 void IrcUserItem::setNick(QString newNick) {