Pass dataChanged through MergedProxyModel

This commit is contained in:
David Sansome 2010-07-04 11:43:17 +00:00
parent 88474551d5
commit 2b58a1e19a
3 changed files with 10 additions and 1 deletions

View File

@ -110,6 +110,8 @@ void MergedProxyModel::setSourceModel(QAbstractItemModel* source_model) {
this, SLOT(RowsInserted(QModelIndex,int,int)));
disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(RowsRemoved(QModelIndex,int,int)));
disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(DataChanged(QModelIndex,QModelIndex)));
}
QAbstractProxyModel::setSourceModel(source_model);
@ -123,6 +125,8 @@ void MergedProxyModel::setSourceModel(QAbstractItemModel* source_model) {
this, SLOT(RowsInserted(QModelIndex,int,int)));
connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(RowsRemoved(QModelIndex,int,int)));
connect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(DataChanged(QModelIndex,QModelIndex)));
}
void MergedProxyModel::SourceModelReset() {
@ -410,3 +414,7 @@ QAbstractItemModel* MergedProxyModel::GetModel(const QModelIndex& source_index)
}
return NULL;
}
void MergedProxyModel::DataChanged(const QModelIndex& top_left, const QModelIndex& bottom_right) {
emit dataChanged(mapFromSource(top_left), mapFromSource(bottom_right));
}

View File

@ -84,6 +84,7 @@ class MergedProxyModel : public QAbstractProxyModel {
void RowsInserted(const QModelIndex& source_parent, int start, int end);
void RowsAboutToBeRemoved(const QModelIndex& source_parent, int start, int end);
void RowsRemoved(const QModelIndex& source_parent, int start, int end);
void DataChanged(const QModelIndex& top_left, const QModelIndex& bottom_right);
private:
QModelIndex GetActualSourceParent(const QModelIndex& source_parent,

View File

@ -194,7 +194,7 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) {
DeviceInfo& info = devices_[i];
info.lister_ = lister;
dataChanged(index(i, 0), index(i, 0));
emit dataChanged(index(i, 0), index(i, 0));
}
}