diff options
| author | Frank Reininghaus <[email protected]> | 2014-06-05 08:50:52 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2014-06-05 08:50:52 +0200 |
| commit | e07468c7840caeff97360edf08826aa38e8d96ae (patch) | |
| tree | 3d81de17ff4470ea5012c23fcc97b6b4a54eee9f /src/kitemviews/kitemlistview.h | |
| parent | 90e27974a4a4a3cb4d08717b5270bea8645b063e (diff) | |
Separate width and height info in the layouting code
By separating the width and height info, we can save some unnecessary
overhead in terms of memory and CPU cycles, and make the calculation of
the height of a row (or the width of a column in Compact View) a bit
simpler.
To achieve this, this patch extends the concept of "logical rows"
(which are actually columns in Compact View) to "logical width" and
"logical height" (which is the actual height and width, respectively, in
Compact View). The distinction between rows/columns and "logical"
rows/columns may be a bit confusing, but the confusion is already in the
current code, and I hope that it will be mitigated a bit by prefixing
the corresponding variables with "logical".
REVIEW: 118454
Diffstat (limited to 'src/kitemviews/kitemlistview.h')
| -rw-r--r-- | src/kitemviews/kitemlistview.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 8a522a686..cf6f27c03 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -194,12 +194,14 @@ public: int lastVisibleIndex() const; /** - * @return Required size for all items in the model. - * The returned value might be larger than KItemListView::itemSize(). + * @return Calculates the required size for all items in the model. + * It might be larger than KItemListView::itemSize(). * In this case the layout grid will be stretched to assure an * unclipped item. + * NOTE: the logical height (width) is actually the + * width (height) if the scroll orientation is Qt::Vertical! */ - void calculateItemSizeHints(QVector<QSizeF>& sizeHints) const; + void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint) const; /** * If set to true, items having child-items can be expanded to show the child-items as @@ -805,7 +807,7 @@ public: virtual void recycle(KItemListWidget* widget); - virtual void calculateItemSizeHints(QVector<QSizeF>& sizeHints, const KItemListView* view) const = 0; + virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const = 0; virtual qreal preferredRoleColumnWidth(const QByteArray& role, int index, @@ -824,7 +826,7 @@ public: virtual KItemListWidget* create(KItemListView* view); - virtual void calculateItemSizeHints(QVector<QSizeF>& sizeHints, const KItemListView* view) const; + virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const; virtual qreal preferredRoleColumnWidth(const QByteArray& role, int index, @@ -857,9 +859,9 @@ KItemListWidget* KItemListWidgetCreator<T>::create(KItemListView* view) } template<class T> -void KItemListWidgetCreator<T>::calculateItemSizeHints(QVector<QSizeF>& sizeHints, const KItemListView* view) const +void KItemListWidgetCreator<T>::calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const { - return m_informant->calculateItemSizeHints(sizeHints, view); + return m_informant->calculateItemSizeHints(logicalHeightHints, logicalWidthHint, view); } template<class T> |
