1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
4 * Based on the Itemviews NG project from Trolltech Labs *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
22 #ifndef KITEMLISTCONTAINER_H
23 #define KITEMLISTCONTAINER_H
25 #include "dolphin_export.h"
27 #include <QAbstractScrollArea>
29 class KItemListController
;
30 class KItemListSmoothScroller
;
35 * @brief Provides a QWidget based scrolling view for a KItemListController.
37 * The model and view are maintained by the KItemListController.
39 * @see KItemListController
41 class DOLPHIN_EXPORT KItemListContainer
: public QAbstractScrollArea
47 * @param controller Controller that maintains the model and the view.
48 * The KItemListContainer takes ownership of the controller
49 * (the parent will be set to the KItemListContainer).
50 * @param parent Optional parent widget.
52 explicit KItemListContainer(KItemListController
* controller
, QWidget
* parent
= nullptr);
53 ~KItemListContainer() override
;
54 KItemListController
* controller() const;
56 void setEnabledFrame(bool enable
);
57 bool enabledFrame() const;
60 void keyPressEvent(QKeyEvent
* event
) override
;
61 void showEvent(QShowEvent
* event
) override
;
62 void resizeEvent(QResizeEvent
* event
) override
;
63 void scrollContentsBy(int dx
, int dy
) override
;
64 void wheelEvent(QWheelEvent
* event
) override
;
67 void slotScrollOrientationChanged(Qt::Orientation current
, Qt::Orientation previous
);
68 void slotModelChanged(KItemModelBase
* current
, KItemModelBase
* previous
);
69 void slotViewChanged(KItemListView
* current
, KItemListView
* previous
);
70 void scrollTo(qreal offset
);
71 void updateScrollOffsetScrollBar();
72 void updateItemOffsetScrollBar();
75 void updateGeometries();
76 void updateSmoothScrollers(Qt::Orientation orientation
);
79 * Helper method for updateScrollOffsetScrollBar(). Updates the scrollbar-policy
80 * to Qt::ScrollBarAlwaysOn for cases where turning off the scrollbar might lead
81 * to an endless layout loop (see bug #293318).
83 void updateScrollOffsetScrollBarPolicy();
86 KItemListController
* m_controller
;
88 KItemListSmoothScroller
* m_horizontalSmoothScroller
;
89 KItemListSmoothScroller
* m_verticalSmoothScroller
;