From 793311dac163592a8b63fc4859fdc054d7a22022 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Tue, 27 Mar 2012 00:44:39 +0200 Subject: KItemListView interface and implementation simplification - Remove KItemListView::preferredRoleColumnWidth() and allow implementing this as part of derived classes from KItemListWidget. Those derived classes are aware about the layout and hence also can provide the preferred role width. - Make KItemListView::itemSizeHint() non-virtual and also allow implementing the size hint as part of derived classes from KItemListWidget. --- src/kitemviews/kfileitemlistwidget.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/kitemviews/kfileitemlistwidget.h') diff --git a/src/kitemviews/kfileitemlistwidget.h b/src/kitemviews/kfileitemlistwidget.h index 3e6cf8d2a..76d090040 100644 --- a/src/kitemviews/kfileitemlistwidget.h +++ b/src/kitemviews/kfileitemlistwidget.h @@ -28,6 +28,9 @@ #include #include +class KItemListView; +class KItemListStyleOption; + class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget : public KItemListWidget { Q_OBJECT @@ -57,12 +60,20 @@ public: virtual QRectF selectionToggleRect() const; /** - * @return Shown string for the role \p role of the item with the values \p values. + * Implementation of KItemListWidgetCreatorBase::itemSizeHint() when + * using the KItemListWidgetCreator-template. + * + * @see KItemListView */ - // TODO: Move this method to a helper class shared by KFileItemListWidget and - // KFileItemListView to share information that is required to calculate the size hints - // in KFileItemListView and to represent the actual data in KFileItemListWidget. - static QString roleText(const QByteArray& role, const QHash& values); + static QSizeF itemSizeHint(int index, const KItemListView* view); + + /** + * Implementation of KItemListWidgetCreatorBase::preferredRoleColumnWidth() when + * using the KItemListWidgetCreator-template. + * + * @see KItemListView + */ + static qreal preferredRoleColumnWidth(const QByteArray& role, int index, const KItemListView* view); protected: /** @@ -126,9 +137,14 @@ private: void drawSiblingsInformation(QPainter* painter); static QPixmap pixmapForIcon(const QString& name, int size); - static TextId roleTextId(const QByteArray& role); static void applyCutEffect(QPixmap& pixmap); static void applyHiddenEffect(QPixmap& pixmap); + static TextId roleTextId(const QByteArray& role); + + /** + * @return Shown string for the role \p role of the item with the values \p values. + */ + static QString roleText(const QByteArray& role, const QHash& values); private: bool m_isCut; -- cgit v1.3.1