┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafael Fernández López <[email protected]>2007-07-13 13:49:21 +0000
committerRafael Fernández López <[email protected]>2007-07-13 13:49:21 +0000
commitf93cc2499d8c1a324625161452985f365d921e35 (patch)
tree1bd72989494af10452ce9facafbf0a576f59292d /src
parent5c5590846d51a0c04a4f3d76dc1bb9ceb6cea497 (diff)
Take in count item sizes. As we want all elements of the same size we check for the biggest one. This way we have visible columns too, what makes everything more ordered,
and to the user eye as well. svn path=/trunk/KDE/kdebase/apps/; revision=687387
Diffstat (limited to 'src')
-rw-r--r--src/kcategorizedview.cpp34
-rw-r--r--src/kcategorizedview_p.h1
2 files changed, 13 insertions, 22 deletions
diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp
index 133fe5d39..1f9e6fda4 100644
--- a/src/kcategorizedview.cpp
+++ b/src/kcategorizedview.cpp
@@ -78,6 +78,7 @@ private:
KCategorizedView::Private::Private(KCategorizedView *listView)
: listView(listView)
, itemCategorizer(0)
+ , biggestItemSize(QSize(0, 0))
, mouseButtonPressed(false)
, isDragging(false)
, dragLeftViewport(false)
@@ -150,14 +151,8 @@ QRect KCategorizedView::Private::visualRectInViewport(const QModelIndex &index)
int viewportWidth = listView->viewport()->width() - listView->spacing();
- // We really need all items to be of same size. Otherwise we cannot do this
- // (ereslibre)
- // QSize itemSize =
- // listView->sizeHintForIndex(proxyModel->mapFromSource(index));
- // int itemHeight = itemSize.height();
- // int itemWidth = itemSize.width();*/
- int itemHeight = 107;
- int itemWidth = 130;
+ int itemHeight = biggestItemSize.height();
+ int itemWidth = biggestItemSize.width();
int itemWidthPlusSeparation = listView->spacing() + itemWidth;
int elementsPerRow = viewportWidth / itemWidthPlusSeparation;
if (!elementsPerRow)
@@ -211,13 +206,8 @@ QRect KCategorizedView::Private::visualCategoryRectInViewport(const QString &cat
int viewportWidth = listView->viewport()->width() - listView->spacing();
- // We really need all items to be of same size. Otherwise we cannot do this
- // (ereslibre)
- // QSize itemSize = listView->sizeHintForIndex(index);
- // int itemHeight = itemSize.height();
- // int itemWidth = itemSize.width();
- int itemHeight = 107;
- int itemWidth = 130;
+ int itemHeight = biggestItemSize.height();
+ int itemWidth = biggestItemSize.width();
int itemWidthPlusSeparation = listView->spacing() + itemWidth;
int elementsPerRow = viewportWidth / itemWidthPlusSeparation;
@@ -947,13 +937,8 @@ QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
const QModelIndex current = selectionModel()->currentIndex();
int viewportWidth = viewport()->width() - spacing();
- // We really need all items to be of same size. Otherwise we cannot do this
- // (ereslibre)
- // QSize itemSize = listView->sizeHintForIndex(index);
- // int itemHeight = itemSize.height();
- // int itemWidth = itemSize.width();
- int itemHeight = 107;
- int itemWidth = 130;
+ int itemHeight = d->biggestItemSize.height();
+ int itemWidth = d->biggestItemSize.width();
int itemWidthPlusSeparation = spacing() + itemWidth;
int elementsPerRow = viewportWidth / itemWidthPlusSeparation;
@@ -1119,6 +1104,11 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
// Add all elements mapped to the source model
for (int k = 0; k < d->proxyModel->rowCount(); k++)
{
+ d->biggestItemSize = QSize(qMax(sizeHintForIndex(d->proxyModel->index(k, 0)).width(),
+ d->biggestItemSize.width()),
+ qMax(sizeHintForIndex(d->proxyModel->index(k, 0)).height(),
+ d->biggestItemSize.height()));
+
d->sourceModelIndexList <<
d->proxyModel->mapToSource(d->proxyModel->index(k, 0));
}
diff --git a/src/kcategorizedview_p.h b/src/kcategorizedview_p.h
index 8ce50441b..45d89aa21 100644
--- a/src/kcategorizedview_p.h
+++ b/src/kcategorizedview_p.h
@@ -123,6 +123,7 @@ public:
// Basic data
KCategorizedView *listView;
KItemCategorizer *itemCategorizer;
+ QSize biggestItemSize;
// Behavior data
bool mouseButtonPressed;