diff --git a/TODO b/TODO index 76ffa5cdb..2b47556b6 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/src/libraryview.cpp b/src/libraryview.cpp index 3b2b705a2..2af232500 100644 --- a/src/libraryview.cpp +++ b/src/libraryview.cpp @@ -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)); +} diff --git a/src/libraryview.h b/src/libraryview.h index a62ad67bb..634d74d1d 100644 --- a/src/libraryview.h +++ b/src/libraryview.h @@ -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);