Sync expanded state to the view for new groups.

This commit is contained in:
Felix Geyer 2012-05-02 15:36:27 +02:00
parent 1ea14e1090
commit eb430d78a0
2 changed files with 10 additions and 0 deletions

View File

@ -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));

View File

@ -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);