properly handling disconnects - this might even fix an antique bug with duplicate...
[quassel.git] / src / client / modelpropertymapper.cpp
index 32dfe7f..a855568 100644 (file)
@@ -35,13 +35,13 @@ ModelPropertyMapper::~ModelPropertyMapper() {
 
 void ModelPropertyMapper::setModel(QAbstractItemModel *model) {
   if(_model) {
-    setSelectionModel(new QItemSelectionModel(model));
     disconnect(_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
               this, SLOT(dataChanged(QModelIndex, QModelIndex)));
   }
   _model = model;
   connect(_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
          this, SLOT(dataChanged(QModelIndex, QModelIndex)));
+  setSelectionModel(new QItemSelectionModel(model));
 }
 
 QAbstractItemModel *ModelPropertyMapper::model() const {
@@ -115,6 +115,5 @@ void ModelPropertyMapper::dataChanged(const QModelIndex &topLeft, const QModelIn
 }
 
 void ModelPropertyMapper::targetDestroyed() {
-  QObject *obj = static_cast<QObject *>(sender());
-  removeMapping(0, 0, obj, QByteArray());
+  removeMapping(0, 0, sender(), QByteArray());
 }