fixed a bug in IrcChannel. Upgrade is strongly advised! Distclean as usual.
authorMarcus Eggenberger <egs@quassel-irc.org>
Mon, 4 Feb 2008 20:28:56 +0000 (20:28 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Mon, 4 Feb 2008 20:28:56 +0000 (20:28 +0000)
src/client/networkmodel.cpp
src/client/networkmodel.h
src/client/treemodel.cpp
src/client/treemodel.h
src/common/ircchannel.cpp
src/common/ircuser.cpp
src/common/network.cpp
version.inc

index 61b269f..f40b726 100644 (file)
@@ -60,7 +60,7 @@ const BufferInfo &BufferItem::bufferInfo() const {
 }
 
 quint64 BufferItem::id() const {
 }
 
 quint64 BufferItem::id() const {
-  return bufferInfo().bufferId().toInt();
+  return qHash(bufferInfo().bufferId());
 }
 
 bool BufferItem::isStatusBuffer() const {
 }
 
 bool BufferItem::isStatusBuffer() const {
@@ -308,7 +308,7 @@ QVariant NetworkItem::data(int column, int role) const {
 }
 
 quint64 NetworkItem::id() const {
 }
 
 quint64 NetworkItem::id() const {
-  return _networkId.toInt();
+  return qHash(_networkId);
 }
 
 void NetworkItem::setActive(bool connected) {
 }
 
 void NetworkItem::setActive(bool connected) {
@@ -470,7 +470,17 @@ IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent)
 }
 
 QString IrcUserItem::nickName() const {
 }
 
 QString IrcUserItem::nickName() const {
-  return _ircUser->nick();
+  if(_ircUser)
+    return _ircUser->nick();
+  else
+    return QString();
+}
+
+bool IrcUserItem::isActive() const {
+  if(_ircUser)
+    return !_ircUser->isAway();
+  else
+    return false;
 }
 
 IrcUser *IrcUserItem::ircUser() {
 }
 
 IrcUser *IrcUserItem::ircUser() {
@@ -478,13 +488,13 @@ IrcUser *IrcUserItem::ircUser() {
 }
 
 quint64 IrcUserItem::id() const {
 }
 
 quint64 IrcUserItem::id() const {
-  return (quint64)_ircUser;
+  return qHash((IrcUser *)_ircUser);
 }
 
 QVariant IrcUserItem::data(int column, int role) const {
   switch(role) {
   case NetworkModel::ItemActiveRole:
 }
 
 QVariant IrcUserItem::data(int column, int role) const {
   switch(role) {
   case NetworkModel::ItemActiveRole:
-    return !_ircUser->isAway();
+    return isActive();
   case NetworkModel::ItemTypeRole:
     return NetworkModel::IrcUserItemType;
   case NetworkModel::BufferIdRole:
   case NetworkModel::ItemTypeRole:
     return NetworkModel::IrcUserItemType;
   case NetworkModel::BufferIdRole:
index 959d89a..63eb569 100644 (file)
@@ -191,6 +191,8 @@ public:
   IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent);
 
   QString nickName() const;
   IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent);
 
   QString nickName() const;
+  bool isActive() const;
+
   IrcUser *ircUser();
   virtual quint64 id() const;
   virtual QVariant data(int column, int role) const;
   IrcUser *ircUser();
   virtual quint64 id() const;
   virtual QVariant data(int column, int role) const;
@@ -200,7 +202,7 @@ private slots:
   void setNick(QString newNick);
 
 private:
   void setNick(QString newNick);
 
 private:
-  IrcUser *_ircUser;
+  QPointer<IrcUser> _ircUser;
 };
 
 
 };
 
 
index 80e7630..0d35ef6 100644 (file)
@@ -311,6 +311,17 @@ TreeModel::TreeModel(const QList<QVariant> &data, QObject *parent)
 {
   rootItem = new SimpleTreeItem(data, 0);
   connectItem(rootItem);
 {
   rootItem = new SimpleTreeItem(data, 0);
   connectItem(rootItem);
+
+  /*
+  connect(this, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
+         this, SLOT(debug_rowsAboutToBeInserted(const QModelIndex &, int, int)));
+  connect(this, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
+         this, SLOT(debug_rowsAboutToBeRemoved(const QModelIndex &, int, int)));
+  connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
+         this, SLOT(debug_rowsInserted(const QModelIndex &, int, int)));
+  connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
+         this, SLOT(debug_rowsRemoved(const QModelIndex &, int, int)));
+  */
 }
 
 TreeModel::~TreeModel() {
 }
 
 TreeModel::~TreeModel() {
@@ -541,3 +552,29 @@ void TreeModel::endRemoveChilds() {
 void TreeModel::clear() {
   rootItem->removeAllChilds();
 }
 void TreeModel::clear() {
   rootItem->removeAllChilds();
 }
+
+void TreeModel::debug_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end) {
+  qDebug() << "debug_rowsAboutToBeInserted" << parent << parent.internalPointer() << parent.data().toString() << rowCount(parent) << start << end;
+}
+
+void TreeModel::debug_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) {
+  qDebug() << "debug_rowsAboutToBeRemoved" << parent << parent.internalPointer() << parent.data().toString() << rowCount(parent) << start << end;
+  QModelIndex child;
+  for(int i = start; i <= end; i++) {
+    child = parent.child(i, 0);
+    qDebug() << "    " << child << child.data().toString(); // << static_cast<AbstractTreeItem *>(parent.child(i, 0).internalPointer())->id();
+  }
+}
+
+void TreeModel::debug_rowsInserted(const QModelIndex &parent, int start, int end) {
+  qDebug() << "debug_rowsInserted" << parent << parent.internalPointer() << parent.data().toString() << rowCount(parent) << start << end;
+  QModelIndex child;
+  for(int i = start; i <= end; i++) {
+    child = parent.child(i, 0);
+    qDebug() << "    " << child << child.data().toString(); // << static_cast<AbstractTreeItem *>(parent.child(i, 0).internalPointer())->id();
+  }
+}
+
+void TreeModel::debug_rowsRemoved(const QModelIndex &parent, int start, int end) {
+  qDebug() << "debug_rowsRemoved" << parent << parent.internalPointer() << parent.data().toString() << rowCount(parent) << start << end;
+}
index 55dafac..6f2575c 100644 (file)
@@ -188,8 +188,12 @@ private:
   };
   ChildStatus _childStatus;
   int _aboutToRemoveOrInsert;
   };
   ChildStatus _childStatus;
   int _aboutToRemoveOrInsert;
-  // QLinkedList<ChildStatus> _childStatus;
 
 
+private slots:
+  void debug_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+  void debug_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+  void debug_rowsInserted(const QModelIndex &parent, int start, int end);
+  void debug_rowsRemoved(const QModelIndex &parent, int start, int end);
 };
 
 #endif
 };
 
 #endif
index e6c809f..38959aa 100644 (file)
@@ -164,6 +164,7 @@ void IrcChannel::part(IrcUser *ircuser) {
     //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
     //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
+    disconnect(ircuser, 0, this, 0);
     emit ircUserParted(ircuser);
     if(network->isMe(ircuser))
        deleteLater();
     emit ircUserParted(ircuser);
     if(network->isMe(ircuser))
        deleteLater();
@@ -241,6 +242,7 @@ void IrcChannel::initSetUserModes(const QVariantMap &usermodes) {
 }
 
 void IrcChannel::ircUserDestroyed() {
 }
 
 void IrcChannel::ircUserDestroyed() {
+  qDebug() << "IrcChannel::ircUserDestroyed()";
   IrcUser *ircUser = static_cast<IrcUser *>(sender());
   Q_ASSERT(ircUser);
   _userModes.remove(ircUser);
   IrcUser *ircUser = static_cast<IrcUser *>(sender());
   Q_ASSERT(ircUser);
   _userModes.remove(ircUser);
index 704934b..99f2ae3 100644 (file)
@@ -49,7 +49,10 @@ IrcUser::IrcUser(const QString &hostmask, Network *network)
 }
 
 IrcUser::~IrcUser() {
 }
 
 IrcUser::~IrcUser() {
-  //qDebug() << nick() << "destroyed.";
+  QList<IrcChannel *> channels = _channels.toList();
+  foreach(IrcChannel *channel, channels) {
+    partChannel(channel);
+  }
 }
 
 // ====================
 }
 
 // ====================
index d3ecab5..8f5680b 100644 (file)
@@ -236,6 +236,7 @@ void Network::removeIrcUser(IrcUser *ircuser) {
     return;
 
   _ircUsers.remove(nick);
     return;
 
   _ircUsers.remove(nick);
+  disconnect(ircuser, 0, this, 0);
   emit ircUserRemoved(nick);
   emit ircUserRemoved(ircuser);
   ircuser->deleteLater();
   emit ircUserRemoved(nick);
   emit ircUserRemoved(ircuser);
   ircuser->deleteLater();
index d6629d4..c0abd2d 100644 (file)
@@ -5,14 +5,14 @@
 
   quasselVersion = "0.2.0-pre";
   quasselDate = "2008-02-04";
 
   quasselVersion = "0.2.0-pre";
   quasselDate = "2008-02-04";
-  quasselBuild = 455;
+  quasselBuild = 456;
 
   //! Minimum client build number the core needs
 
   //! Minimum client build number the core needs
-  clientBuildNeeded = 437;
+  clientBuildNeeded = 456;
   clientVersionNeeded = quasselVersion;
 
   //! Minimum core build number the client needs
   clientVersionNeeded = quasselVersion;
 
   //! Minimum core build number the client needs
-  coreBuildNeeded = 437;
+  coreBuildNeeded = 456;
   coreVersionNeeded = quasselVersion;
 
 }
   coreVersionNeeded = quasselVersion;
 
 }