From 53bdec9b58131014dcec9d6bc7d48e1aa01be979 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 6 Dec 2008 20:06:04 +0000 Subject: Fixed serious usability issue: QAbstractItemView::setAutoScroll() is not usable when trying to select items outside the visible view area (reported to Qt Software with bug ID #214542) -> implemented custom auto scrolling algorithm. BUG: 165531 svn path=/trunk/KDE/kdebase/apps/; revision=893546 --- src/dolphinviewautoscroller.h | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/dolphinviewautoscroller.h (limited to 'src/dolphinviewautoscroller.h') diff --git a/src/dolphinviewautoscroller.h b/src/dolphinviewautoscroller.h new file mode 100644 index 000000000..c02112b7b --- /dev/null +++ b/src/dolphinviewautoscroller.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2008 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef DOLPHINVIEWAUTOSCROLLER_H +#define DOLPHINVIEWAUTOSCROLLER_H + +#include + +class QAbstractItemView; +class QTimer; + +/** + * @brief Assures that an autoscrolling is done for item views. + * + * This is a workaround as QAbstractItemView::setAutoScroll() is not usable + * when selecting items (see Qt issue #214542). + */ +class DolphinViewAutoScroller : public QObject +{ + Q_OBJECT + +public: + DolphinViewAutoScroller(QAbstractItemView* parent); + virtual ~DolphinViewAutoScroller(); + +protected: + virtual bool eventFilter(QObject* watched, QEvent* event); + +private slots: + void scrollViewport(); + +private: + void triggerAutoScroll(); + void stopAutoScroll(); + +private: + bool m_rubberBandSelection; + int m_scrollInc; + QAbstractItemView* m_itemView; + QTimer* m_timer; +}; + +#endif -- cgit v1.3