Index: src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.cpp
===================================================================
--- src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.cpp	(revision 47f0e469e70ba79ff1b52d056bf13f5b859efce4)
+++ src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.cpp	(revision 5a9e34e889a8bb41b432e388eef49d7d852b91b0)
@@ -35,96 +35,22 @@
 #include "QtMoleculeItem.hpp"
 
-#include <QModelIndex>
-
 #include "UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp"
 
 #include "CodePatterns/MemDebug.hpp"
 
-#include "CodePatterns/Assert.hpp"
-#include "CodePatterns/toString.hpp"
-
-#include "CodePatterns/Observer/Notification.hpp"
-
-#include <algorithm>
-
-#include <boost/thread/locks.hpp>
-
-#include "Descriptors/MoleculeIdDescriptor.hpp"
-#include "molecule.hpp"
-#include "World.hpp"
-
 QtMoleculeItem::QtMoleculeItem(
-     const moleculeId_t _molid,
-     const channellist_t &_channellist,
+    QtObservedMolecule::ptr &_ObservedMolecule,
      const enum MoveTypes _movetype,
-     const emitDirtyState_t _emitDirtyState,
-     const emitSubjectKilledState_t _emitSubjectKilledState) :
-  Observer("QtMoleculeItem"),
-  molid(_molid),
+     const emitDirtyState_t _emitDirtyState) :
+  ObservedMolecule(_ObservedMolecule),
   movetype(_movetype),
-  channellist(_channellist),
-  owner(NULL),
   dirty(true),
-  emitDirtyState(_emitDirtyState),
-  emitSubjectKilledState(_emitSubjectKilledState)
+  emitDirtyState(_emitDirtyState)
 {
-  // BUG: We cannot sign on here as then and again we catch "pure virtual function called"
-  // this makes no sense as both the Observer part (which also has a recievedNotification())
-  // nor QtMoleculeItem's vtable have been fully created.
-//  signOnToMolecule();
   setFlags(flags() | Qt::ItemIsSelectable);
-}
-
-void QtMoleculeItem::signOnToMolecule()
-{
-  // count the number of threads entering the function
-  std::cout << "QtMoleculeItem::signOnToMolecule() called for " << this << std::endl;
-  const molecule * const mol = const_cast<const World &>(World::getInstance()).
-      getMolecule(MoleculeById(molid));
-  if (mol != NULL) {
-    owner_mutex.lock();
-    if (owner == NULL) {
-      owner_mutex.unlock();
-      const Observable *owner_copy = static_cast<const Observable *>(mol);
-      for (channellist_t::const_iterator channeliter = channellist.begin();
-          channeliter != channellist.end(); ++channeliter)
-        owner_copy->signOn(this, *channeliter);
-      owner_mutex.lock();
-      owner = owner_copy;
-      owner_mutex.unlock();
-      std::cout << "QtMoleculeItem " << this << " has signed on to " << owner << std::endl;
-    } else
-      owner_mutex.unlock();
-  }
-}
-
-void QtMoleculeItem::signOffFromMolecule()
-{
-  // prevent via owner that another thread enters the function again
-  // (re-entrancy)
-  const Observable *owner_copy;
-  {
-    boost::recursive_mutex::scoped_lock lock(owner_mutex);
-    if (owner != NULL) {
-      owner_copy = owner;
-      owner = NULL;
-    }
-  }
-  std::cout << "QtMoleculeItem::signOffFromMolecule() called for " << this << std::endl;
-  if (owner_copy != NULL) {
-    for (channellist_t::const_iterator channeliter = channellist.begin();
-        channeliter != channellist.end(); ++channeliter)
-      owner_copy->signOff(this, *channeliter);
-    std::cout << "QtMoleculeItem " << this << " has signed off from " << owner_copy << std::endl;
-    owner_copy = NULL;
-  }
 }
 
 QtMoleculeItem::~QtMoleculeItem()
 {
-  // BUG: We cannot sign off here as then and again we catch "pure virtual function called"
-  // this makes no sense as neither the Observer part (which also has a recievedNotification())
-  // nor QtMoleculeItem's vtable have yet been destroyed.
-  signOffFromMolecule();
 }
 
@@ -136,43 +62,2 @@
   }
 }
-
-void QtMoleculeItem::update(Observable *publisher)
-{}
-
-void QtMoleculeItem::recieveNotification(Observable *publisher, Notification_ptr notification)
-{
-  if (dynamic_cast<molecule *>(publisher) != NULL) {
-    if (notification->getChannelNo() == molecule::AboutToBeRemoved) {
-      signOffFromMolecule();
-      // prevent any remaining updates from accessing the molecule
-      //molid = -1;
-      dirty = false;
-    } else {
-      channellist_t::const_iterator iter =
-          std::find(channellist.begin(), channellist.end(), notification->getChannelNo());
-      if (iter != channellist.end()) {
-        dirty = true;
-        emitDirtyState(getMoleculeId(), getType(), movetype);
-      } else {
-        ASSERT(0,
-            "QtMoleculeItem::recieveNotification() - received notification to channel "
-            +toString(notification->getChannelNo())+" we are not subscribed to.");
-      }
-    }
-  }
-}
-
-void QtMoleculeItem::subjectKilled(Observable *publisher)
-{
-//  signOffFromMolecule();
-  dirty = false;
-  emitSubjectKilledState(getMoleculeId());
-}
-
-const molecule * const QtMoleculeItem::getMolecule() const
-{
-  const molecule * const mol = const_cast<const World &>(World::getInstance()).getMolecule(MoleculeById(molid));
-//  ASSERT (mol != NULL,
-//      "QtMoleculeItem::getMolecule() - mol with "+toString(molid)+" is gone.");
-  return mol;
-}
