┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistviewlayouter.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-10-15 22:55:01 +0200
committerPeter Penz <[email protected]>2011-10-15 22:55:01 +0200
commit283f97ac27c3cfe5c72682b0843503e31643a612 (patch)
tree35325115a5e5c001e1e307acc580af572bad0ac1 /src/kitemviews/kitemlistviewlayouter.cpp
parenta49109b09a191b73f3fda8b65c29e9c6c9bd33d8 (diff)
Interface cleanups to prepare the return of "grouped sorting"
- Rename setCategorizedSorting() to setGroupedSorting() - Change the model interface to allow enabling/disabling grouping without the need to declare a role (the sort role will be taken). - Add dummy group role implementation in KFileItemModel The grouping code itself requires some cleanups and might crash at the moment or lead to weird layouts.
Diffstat (limited to 'src/kitemviews/kitemlistviewlayouter.cpp')
-rw-r--r--src/kitemviews/kitemlistviewlayouter.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/kitemviews/kitemlistviewlayouter.cpp b/src/kitemviews/kitemlistviewlayouter.cpp
index f829824f0..30881abfd 100644
--- a/src/kitemviews/kitemlistviewlayouter.cpp
+++ b/src/kitemviews/kitemlistviewlayouter.cpp
@@ -332,18 +332,16 @@ void KItemListViewLayouter::doLayout()
m_maximumItemOffset = 0;
}
- m_grouped = !m_model->groupRole().isEmpty();
- /*if (m_grouped) {
+ m_grouped = m_model->groupedSorting();
+ if (m_grouped) {
createGroupHeaders();
const int lastGroupItemCount = m_model->count() - m_groups.last().firstItemIndex;
- m_maximumOffset = m_groups.last().y + (lastGroupItemCount / m_columnCount) * m_rowHeight;
+ m_maximumScrollOffset = m_groups.last().y + (lastGroupItemCount / m_columnCount) * itemSize.height();
if (lastGroupItemCount % m_columnCount != 0) {
- m_maximumOffset += m_rowHeight;
+ m_maximumScrollOffset += itemSize.height();
}
- } else {*/
- // m_maximumOffset = m_minimumRowHeight * rowCount;
- //}
+ }
#ifdef KITEMLISTVIEWLAYOUTER_DEBUG
kDebug() << "[TIME] doLayout() for " << m_model->count() << "items:" << timer.elapsed();
@@ -480,7 +478,6 @@ void KItemListViewLayouter::updateGroupedVisibleIndexes()
m_lastVisibleIndex = nextGroupIndex - 1;
}
}
- //Q_ASSERT(m_lastVisibleIndex < m_model->count());
m_lastVisibleIndex = qBound(0, m_lastVisibleIndex, maxIndex);
m_visibleIndexesDirty = false;
@@ -491,14 +488,13 @@ void KItemListViewLayouter::createGroupHeaders()
m_groups.clear();
m_groupIndexes.clear();
- // TODO:
- QList<int> numbers;
- numbers << 0 << 5 << 6 << 13 << 20 << 25 << 30 << 35 << 50;
+ const QList<QPair<int, QVariant> > groups = m_model->groups();
qreal y = 0;
- for (int i = 0; i < numbers.count(); ++i) {
+ for (int i = 0; i < groups.count(); ++i) {
+ const int firstItemIndex = groups.at(i).first;
if (i > 0) {
- const int previousGroupItemCount = numbers[i] - m_groups.last().firstItemIndex;
+ const int previousGroupItemCount = firstItemIndex - m_groups.last().firstItemIndex;
int previousGroupRowCount = previousGroupItemCount / m_columnCount;
if (previousGroupItemCount % m_columnCount != 0) {
++previousGroupRowCount;
@@ -509,11 +505,11 @@ void KItemListViewLayouter::createGroupHeaders()
y += HeaderHeight;
ItemGroup itemGroup;
- itemGroup.firstItemIndex = numbers[i];
+ itemGroup.firstItemIndex = firstItemIndex;
itemGroup.y = y;
m_groups.append(itemGroup);
- m_groupIndexes.insert(itemGroup.firstItemIndex);
+ m_groupIndexes.insert(firstItemIndex);
}
}