diff --git a/src/gui/GroupView.cpp b/src/gui/GroupView.cpp index 32621ce94..dc5c76bff 100644 --- a/src/gui/GroupView.cpp +++ b/src/gui/GroupView.cpp @@ -38,6 +38,7 @@ GroupView::GroupView(Database* db, QWidget* parent) recInitExpanded(db->rootGroup()); connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expandedChanged(QModelIndex))); connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(expandedChanged(QModelIndex))); + connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(syncExpandedState(QModelIndex,int,int))); setCurrentIndex(m_model->index(0, 0)); // invoke later so the EntryView is connected @@ -102,6 +103,14 @@ void GroupView::emitGroupChanged() Q_EMIT groupChanged(currentGroup()); } +void GroupView::syncExpandedState(const QModelIndex& parent, int start, int end) +{ + for (int row = start; row <= end; row++) { + Group* group = m_model->groupFromIndex(m_model->index(row, 0, parent)); + recInitExpanded(group); + } +} + void GroupView::setCurrentGroup(Group* group) { setCurrentIndex(m_model->index(group)); diff --git a/src/gui/GroupView.h b/src/gui/GroupView.h index f07cbf027..af87dbe89 100644 --- a/src/gui/GroupView.h +++ b/src/gui/GroupView.h @@ -42,6 +42,7 @@ private Q_SLOTS: void expandedChanged(const QModelIndex& index); void emitGroupChanged(const QModelIndex& index); void emitGroupChanged(); + void syncExpandedState(const QModelIndex& parent, int start, int end); protected: void dragMoveEvent(QDragMoveEvent* event);