From 215a0d9e8acf82af59f825fa3ce28c9394257bad Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 15 Jul 2014 07:23:11 +0000 Subject: fixed freezing when shift+home and shift+end pressed git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4375 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Ui/skinned/keyboardmanager.cpp | 6 ++---- src/qmmpui/playlistmodel.cpp | 17 +++++++++++++++++ src/qmmpui/playlistmodel.h | 9 ++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/Ui/skinned/keyboardmanager.cpp b/src/plugins/Ui/skinned/keyboardmanager.cpp index a4f2ca93b..aef054584 100644 --- a/src/plugins/Ui/skinned/keyboardmanager.cpp +++ b/src/plugins/Ui/skinned/keyboardmanager.cpp @@ -265,8 +265,7 @@ void KeyboardManager::keyHome(QKeyEvent *ke) m_listWidget->scroll (0); if(ke->modifiers() & Qt::ShiftModifier) { - for(int i = 0; i <= m_listWidget->anchorIndex(); ++i) - m_listWidget->model()->setSelected (i, true); + m_listWidget->model()->setSelected (0, m_listWidget->anchorIndex(), true); } else if(m_listWidget->model()->count() != 0) { @@ -282,8 +281,7 @@ void KeyboardManager::keyEnd(QKeyEvent *ke) m_listWidget->scroll(scroll_to); if(ke->modifiers() & Qt::ShiftModifier) { - for(int i = m_listWidget->anchorIndex(); i < m_listWidget->model()->count(); ++i) - m_listWidget->model()->setSelected (i, true); + m_listWidget->model()->setSelected (m_listWidget->anchorIndex(), m_listWidget->model()->count() - 1, true); } else if(m_listWidget->model()->count() > 0) { diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index 62a5003e6..b3118c62c 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -421,6 +421,23 @@ void PlayListModel::setSelected(QList items, bool selected) emit listChanged(); } +void PlayListModel::setSelected(int first, int last, bool selected) +{ + if(first > last) + { + setSelected(last, first, selected); + return; + } + for(int index = first; index <= last; ++index) + { + PlayListItem *i = item(index); + if(!i) + continue; + i->setSelected(selected); + } + emit listChanged(); +} + void PlayListModel::removeSelected() { removeSelection(false); diff --git a/src/qmmpui/playlistmodel.h b/src/qmmpui/playlistmodel.h index 63eb9fc77..77ad9c50a 100644 --- a/src/qmmpui/playlistmodel.h +++ b/src/qmmpui/playlistmodel.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2013 by Ilya Kotov * + * Copyright (C) 2006-2014 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -182,6 +182,13 @@ public: * @param selected Selection state (\b true - select, \b false - unselect) */ void setSelected(QList items, bool selected = true); + /*! + * Sets the selected state of the list of items range + * @param firts Firts item in the range + * @param last Last item in the range + * @param selected Selection state (\b true - select, \b false - unselect) + */ + void setSelected(int first, int last, bool selected = true); /*! * Advances to the next item. Returns \b false if next iten doesn't exist, * otherwise returns \b true -- cgit v1.2.3-13-gbd6f