When doing a keyboard search in the library view, scroll so that the index is at the top of the viewport instead of at the bottom. Fixes issue #354
This commit is contained in:
parent
98c97d13d6
commit
48830f2acc
@ -79,7 +79,8 @@ LibraryView::LibraryView(QWidget* parent)
|
||||
library_(NULL),
|
||||
total_song_count_(-1),
|
||||
nomusic_(":nomusic.png"),
|
||||
context_menu_(new QMenu(this))
|
||||
context_menu_(new QMenu(this)),
|
||||
is_in_keyboard_search_(false)
|
||||
{
|
||||
setItemDelegate(new LibraryItemDelegate(this));
|
||||
|
||||
@ -208,3 +209,16 @@ void LibraryView::AddToPlaylist() {
|
||||
|
||||
emit AddToPlaylist(context_menu_index_);
|
||||
}
|
||||
|
||||
void LibraryView::keyboardSearch(const QString &search) {
|
||||
is_in_keyboard_search_ = true;
|
||||
QTreeView::keyboardSearch(search);
|
||||
is_in_keyboard_search_ = false;
|
||||
}
|
||||
|
||||
void LibraryView::scrollTo(const QModelIndex &index, ScrollHint hint) {
|
||||
if (is_in_keyboard_search_)
|
||||
QTreeView::scrollTo(index, QAbstractItemView::PositionAtTop);
|
||||
else
|
||||
QTreeView::scrollTo(index, hint);
|
||||
}
|
||||
|
@ -39,6 +39,10 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
|
||||
void SetLibrary(LibraryModel* library);
|
||||
|
||||
// QTreeView
|
||||
void keyboardSearch(const QString &search);
|
||||
void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
|
||||
|
||||
public slots:
|
||||
void TotalSongCountUpdated(int count);
|
||||
void ReloadSettings();
|
||||
@ -76,6 +80,8 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
QAction* add_to_playlist_;
|
||||
QAction* show_in_various_;
|
||||
QAction* no_show_in_various_;
|
||||
|
||||
bool is_in_keyboard_search_;
|
||||
};
|
||||
|
||||
#endif // LIBRARYVIEW_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user