From aee65350437770b22b289e2c7ec5a5a4436e39a6 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sun, 25 Sep 2011 19:52:33 +0200 Subject: Provide scrollbar for large items If an item does not fit into the available width/height a scrollbar should be provided (e.g. typically this represents the horizontal scrollbar in the details-view where the width can be larger than the than the visible width). Currently the interaction with the scrollbar is not implemented but this will be a quite minor task in comparison to this patch. --- src/kitemviews/kitemlistview.h | 51 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'src/kitemviews/kitemlistview.h') diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 75a298a1e..d6b0d5a77 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -65,7 +65,7 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListView : public QGraphicsWidget { Q_OBJECT - Q_PROPERTY(qreal offset READ offset WRITE setOffset) + Q_PROPERTY(qreal scrollOffset READ scrollOffset WRITE setScrollOffset) public: KItemListView(QGraphicsWidget* parent = 0); @@ -78,10 +78,15 @@ public: QSizeF itemSize() const; // TODO: add note that offset is not checked against maximumOffset, only against 0. - void setOffset(qreal offset); - qreal offset() const; + void setScrollOffset(qreal offset); + qreal scrollOffset() const; - qreal maximumOffset() const; + qreal maximumScrollOffset() const; + + void setItemOffset(qreal scrollOffset); + qreal itemOffset() const; + + qreal maximumItemOffset() const; void setVisibleRoles(const QList& roles); QList visibleRoles() const; @@ -159,7 +164,7 @@ public: * is empty. This allows to have dynamic but equal role sizes between * all items. Per default an empty hash is returned. */ - virtual QHash visibleRoleSizes() const; + virtual QHash visibleRolesSizes() const; /** * @return The bounding rectangle of the item relative to the top/left of @@ -193,8 +198,10 @@ public: virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); signals: - void offsetChanged(qreal current, qreal previous); - void maximumOffsetChanged(qreal current, qreal previous); + void scrollOffsetChanged(qreal current, qreal previous); + void maximumScrollOffsetChanged(qreal current, qreal previous); + void itemOffsetChanged(qreal current, qreal previous); + void maximumItemOffsetChanged(qreal current, qreal previous); void scrollTo(qreal newOffset); protected: @@ -215,7 +222,7 @@ protected: virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous); virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous); - virtual void onOffsetChanged(qreal current, qreal previous); + virtual void onScrollOffsetChanged(qreal current, qreal previous); virtual void onVisibleRolesChanged(const QList& current, const QList& previous); virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous); @@ -232,15 +239,6 @@ protected: QList visibleItemListWidgets() const; - /** - * Marks the visible roles as dirty so that they will get updated when doing the next - * layout. The visible roles will only get marked as dirty if an empty item-size is - * given and if the roles have not already been customized by the user by adjusting - * the view-header. - * @return True if the visible roles have been marked as dirty. - */ - bool markVisibleRolesSizesAsDirty(); - /** @reimp */ virtual void resizeEvent(QGraphicsSceneResizeEvent* event); @@ -320,12 +318,6 @@ private: */ void setLayouterSize(const QSizeF& size, SizeType sizeType); - /** - * Updates the m_visibleRoleSizes property and applies the dynamic - * size to the layouter. - */ - void applyDynamicItemSize(); - /** * Helper method for createWidget() and setWidgetIndex() to update the properties * of the itemlist widget. @@ -343,6 +335,13 @@ private: */ QHash headerRolesWidths() const; + /** + * Updates m_visibleRoleSizes by calling KItemListView::visibleRoleSizes() + * if the m_itemRect is empty and no custom header-widths are used + * (see m_useHeaderWidths). + */ + void updateVisibleRoleSizes(); + /** * Helper function for triggerAutoScrolling(). * @param pos Logical position of the mouse relative to the range. @@ -377,8 +376,10 @@ private: KItemListViewAnimation* m_animation; QTimer* m_layoutTimer; // Triggers an asynchronous doLayout() call. - qreal m_oldOffset; - qreal m_oldMaximumOffset; + qreal m_oldScrollOffset; + qreal m_oldMaximumScrollOffset; + qreal m_oldItemOffset; + qreal m_oldMaximumItemOffset; bool m_skipAutoScrollForRubberBand; KItemListRubberBand* m_rubberBand; -- cgit v1.3