From ae4d11d918938fd9087f2035dac247969c1f2313 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 21 Apr 2012 21:28:16 +0200 Subject: Prepare view-engine for non-KFileItem usecase Up to now the view-engine only provided a model-implementation that supports file-items. The view-engine always had been designed to be able to work with any kind of model, so now a KStandardItemModel is available. The plan is to convert the places panel to the new view-engine. It should be no problem to fix this until the feature freeze - in the worst case the places-panel code could be reverted while still keeping the KStandardItemModel changes. --- src/kitemviews/kitemlistwidget.h | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/kitemviews/kitemlistwidget.h') diff --git a/src/kitemviews/kitemlistwidget.h b/src/kitemviews/kitemlistwidget.h index 8a28913b6..fdb07d62e 100644 --- a/src/kitemviews/kitemlistwidget.h +++ b/src/kitemviews/kitemlistwidget.h @@ -32,8 +32,30 @@ #include class KItemListSelectionToggle; +class KItemListView; class QPropertyAnimation; +/** + * @brief Provides information for creating an instance of KItemListWidget. + * + * KItemListView only creates KItemListWidget instances for the visible + * area. For calculating the required size of all items the expected + * size for the invisible items must be accessible. KItemListWidgetInformant + * provides this information. + */ +class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetInformant +{ +public: + KItemListWidgetInformant(); + virtual ~KItemListWidgetInformant(); + + virtual QSizeF itemSizeHint(int index, const KItemListView* view) const = 0; + + virtual qreal preferredRoleColumnWidth(const QByteArray& role, + int index, + const KItemListView* view) const = 0; +}; + /** * @brief Widget that shows a visible item from the model. * @@ -46,7 +68,7 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListWidget : public QGraphicsWidget Q_OBJECT public: - KItemListWidget(QGraphicsItem* parent); + KItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent); virtual ~KItemListWidget(); void setIndex(int index); @@ -176,6 +198,8 @@ protected: */ qreal hoverOpacity() const; + const KItemListWidgetInformant* informant() const; + private slots: void slotHoverAnimationFinished(); @@ -188,6 +212,7 @@ private: private: Q_PROPERTY(qreal hoverOpacity READ hoverOpacity WRITE setHoverOpacity) + KItemListWidgetInformant* m_informant; int m_index; bool m_selected; bool m_current; @@ -208,6 +233,12 @@ private: QByteArray m_editedRole; }; + +inline const KItemListWidgetInformant* KItemListWidget::informant() const +{ + return m_informant; +} + #endif -- cgit v1.3.1