mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Speed fixes
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ee7f579242
commit
6f74618d9c
1 changed files with 12 additions and 4 deletions
|
@ -50,25 +50,33 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS
|
||||||
struct dive *dive = (struct dive*) model->data(index, TreeItemDT::DIVE_ROLE).value<void*>();
|
struct dive *dive = (struct dive*) model->data(index, TreeItemDT::DIVE_ROLE).value<void*>();
|
||||||
if (!dive) { // is's a trip!
|
if (!dive) { // is's a trip!
|
||||||
if (model->rowCount(index)) {
|
if (model->rowCount(index)) {
|
||||||
expand(index); // leave this - even if it looks like it shouldn't be here. looks like I'v found a Qt bug.
|
expand(index); // leave this - even if it looks like it shouldn't be here. looks like I'v found a Qt bug.
|
||||||
|
// the subselection is removed, but the painting is not. this cleans the area.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QModelIndex> parents;
|
||||||
Q_FOREACH(const QModelIndex& index, selected.indexes()) {
|
Q_FOREACH(const QModelIndex& index, selected.indexes()) {
|
||||||
const QAbstractItemModel *model = index.model();
|
const QAbstractItemModel *model = index.model();
|
||||||
struct dive *dive = (struct dive*) model->data(index, TreeItemDT::DIVE_ROLE).value<void*>();
|
struct dive *dive = (struct dive*) model->data(index, TreeItemDT::DIVE_ROLE).value<void*>();
|
||||||
if (!dive) { // is's a trip!
|
if (!dive) { // is's a trip!
|
||||||
if (model->rowCount(index)) {
|
if (model->rowCount(index)) {
|
||||||
expand(index);
|
|
||||||
QItemSelection selection;
|
QItemSelection selection;
|
||||||
selection.select(index.child(0,0), index.child(model->rowCount(index) -1 , 0));
|
selection.select(index.child(0,0), index.child(model->rowCount(index) -1 , 0));
|
||||||
selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::NoUpdate);
|
selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::NoUpdate);
|
||||||
|
if (!isExpanded(index)){
|
||||||
|
expand(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (!parents.contains(index.parent())){
|
||||||
expand(index.parent());
|
parents.push_back(index.parent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_FOREACH(const QModelIndex& index, parents){
|
||||||
|
expand(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue