properly handling disconnects - this might even fix an antique bug with duplicate...
[quassel.git] / src / client / modelpropertymapper.cpp
index 890eda4..a855568 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-07 by the Quassel IRC Team                         *
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -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());
 }