parent
7bc5579fb7
commit
5f78e1a983
|
@ -22,7 +22,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
@ -120,13 +119,15 @@ void MergedProxyModel::RemoveSubModel(const QModelIndex &source_parent) {
|
||||||
|
|
||||||
// Remove all the children of the item that got deleted
|
// Remove all the children of the item that got deleted
|
||||||
QModelIndex proxy_parent = mapFromSource(source_parent);
|
QModelIndex proxy_parent = mapFromSource(source_parent);
|
||||||
|
if (proxy_parent.isValid()) {
|
||||||
// We can't know how many children it had, since we can't dereference it
|
const int row_count = rowCount(proxy_parent);
|
||||||
// FIXME: This is a bad idea.
|
if (row_count > 0) {
|
||||||
resetting_model_ = submodel;
|
resetting_model_ = submodel;
|
||||||
beginRemoveRows(proxy_parent, 0, std::numeric_limits<int>::max() - 1);
|
beginRemoveRows(proxy_parent, 0, row_count - 1);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
resetting_model_ = nullptr;
|
resetting_model_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Delete all the mappings that reference the submodel
|
// Delete all the mappings that reference the submodel
|
||||||
auto it = p_->mappings_.get<tag_by_pointer>().begin();
|
auto it = p_->mappings_.get<tag_by_pointer>().begin();
|
||||||
|
@ -192,10 +193,15 @@ void MergedProxyModel::SubModelAboutToBeReset() {
|
||||||
QModelIndex source_parent = merge_points_.value(submodel);
|
QModelIndex source_parent = merge_points_.value(submodel);
|
||||||
QModelIndex proxy_parent = mapFromSource(source_parent);
|
QModelIndex proxy_parent = mapFromSource(source_parent);
|
||||||
|
|
||||||
resetting_model_ = submodel;
|
if (proxy_parent.isValid()) {
|
||||||
beginRemoveRows(proxy_parent, 0, submodel->rowCount());
|
const int row_count = submodel->rowCount();
|
||||||
endRemoveRows();
|
if (row_count > 0) {
|
||||||
resetting_model_ = nullptr;
|
resetting_model_ = submodel;
|
||||||
|
beginRemoveRows(proxy_parent, 0, row_count - 1);
|
||||||
|
endRemoveRows();
|
||||||
|
resetting_model_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Delete all the mappings that reference the submodel
|
// Delete all the mappings that reference the submodel
|
||||||
auto it = p_->mappings_.get<tag_by_pointer>().begin();
|
auto it = p_->mappings_.get<tag_by_pointer>().begin();
|
||||||
|
|
Loading…
Reference in New Issue