File indexing completed on 2024-05-19 05:48:09
0001 /* 0002 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KITEMLISTSIZEHINTRESOLVER_H 0008 #define KITEMLISTSIZEHINTRESOLVER_H 0009 0010 #include "dolphin_export.h" 0011 #include "kitemviews/kitemmodelbase.h" 0012 0013 #include <QSizeF> 0014 #include <QVector> 0015 0016 class KItemListView; 0017 0018 /** 0019 * @brief Calculates and caches the sizehints of items in KItemListView. 0020 */ 0021 class DOLPHIN_EXPORT KItemListSizeHintResolver 0022 { 0023 public: 0024 explicit KItemListSizeHintResolver(const KItemListView *itemListView); 0025 virtual ~KItemListSizeHintResolver(); 0026 QSizeF minSizeHint(); 0027 QSizeF sizeHint(int index); 0028 bool isElided(int index); 0029 0030 void itemsInserted(const KItemRangeList &itemRanges); 0031 void itemsRemoved(const KItemRangeList &itemRanges); 0032 void itemsMoved(const KItemRange &range, const QList<int> &movedToIndexes); 0033 void itemsChanged(int index, int count, const QSet<QByteArray> &roles); 0034 0035 void clearCache(); 0036 void updateCache(); 0037 0038 private: 0039 const KItemListView *m_itemListView; 0040 mutable QVector<std::pair<qreal /* height */, bool /* isElided */>> m_logicalHeightHintCache; 0041 mutable qreal m_logicalWidthHint; 0042 mutable qreal m_minHeightHint; 0043 bool m_needsResolving; 0044 }; 0045 0046 #endif