┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistwidget.h
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-21 21:28:16 +0200
committerPeter Penz <[email protected]>2012-04-21 21:32:42 +0200
commitae4d11d918938fd9087f2035dac247969c1f2313 (patch)
tree0303667797c81814b46b9ed5ed20b48ef31f2d71 /src/kitemviews/kitemlistwidget.h
parent47d7cdffdd2d2c04067a5088eaeff67add53dde3 (diff)
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.
Diffstat (limited to 'src/kitemviews/kitemlistwidget.h')
-rw-r--r--src/kitemviews/kitemlistwidget.h33
1 files changed, 32 insertions, 1 deletions
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,9 +32,31 @@
#include <QStyle>
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.
*
* For showing an item from a custom model it is required to at least overwrite KItemListWidget::paint().
@@ -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