If there's only one node in a library item then expand it when expanding the parent

This commit is contained in:
David Sansome 2010-01-17 21:22:56 +00:00
parent f950701620
commit 1230084dbf
3 changed files with 10 additions and 1 deletions

1
TODO
View File

@ -8,7 +8,6 @@
- Configuration for:
- crossfading
- osd
- If there's only one node in a library item then expand it when expanding the parent
- Edit tags in playlist view
- Disabled fields in tag editor

View File

@ -59,6 +59,8 @@ LibraryView::LibraryView(QWidget* parent)
nomusic_(":nomusic.png")
{
setItemDelegate(new LibraryItemDelegate(this));
connect(this, SIGNAL(expanded(QModelIndex)), SLOT(ItemExpanded(QModelIndex)));
}
void LibraryView::SetLibrary(Library *library) {
@ -137,3 +139,8 @@ bool LibraryView::RecursivelyExpand(const QModelIndex& index, int* count) {
return true;
}
void LibraryView::ItemExpanded(const QModelIndex& index) {
if (model()->rowCount(index) == 1)
expand(model()->index(0, 0, index));
}

View File

@ -34,6 +34,9 @@ class LibraryView : public QTreeView {
void paintEvent(QPaintEvent* event);
void mouseReleaseEvent(QMouseEvent* e);
private slots:
void ItemExpanded(const QModelIndex& index);
private:
void RecheckIsEmpty();
bool RecursivelyExpand(const QModelIndex& index, int* count);