]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix a couple of crashes. First was to avoid problem caused by KIconLoader::global...
authorRobert Knight <robertknight@gmail.com>
Mon, 23 Jul 2007 23:08:47 +0000 (23:08 +0000)
committerRobert Knight <robertknight@gmail.com>
Mon, 23 Jul 2007 23:08:47 +0000 (23:08 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=691574

src/dolphinitemcategorizer.cpp
src/kcategorizedview.cpp
src/kcategorizedview_p.h

index e51f5f52fcfa520bddb215c52a72f58fb913a91e..d5c6d4e287c0d23510851ff3a85ca6fd73ff56cc 100644 (file)
@@ -199,8 +199,8 @@ void DolphinItemCategorizer::drawCategory(const QModelIndex &index,
                                           QPainter *painter) const
 {
     QRect starRect = option.rect;
                                           QPainter *painter) const
 {
     QRect starRect = option.rect;
-    int iconSize = KIconLoader::global()->theme()->defaultSize(K3Icon::Small);
 
 
+    int iconSize =  KIconLoader::global()->currentSize(K3Icon::Small);                       
     const QString category = categoryForItem(index, sortRole);
 
     QColor color = option.palette.color(QPalette::Text);
     const QString category = categoryForItem(index, sortRole);
 
     QColor color = option.palette.color(QPalette::Text);
@@ -366,7 +366,7 @@ void DolphinItemCategorizer::drawCategory(const QModelIndex &index,
 
 int DolphinItemCategorizer::categoryHeight(const QStyleOption &option) const
 {
 
 int DolphinItemCategorizer::categoryHeight(const QStyleOption &option) const
 {
-    int iconSize = KIconLoader::global()->theme()->defaultSize(K3Icon::Small);
+    int iconSize = KIconLoader::global()->currentSize(K3Icon::Small);
 
     return qMax(option.fontMetrics.height() + (iconSize / 4) * 2 + 2, iconSize + (iconSize / 4) * 2 + 2) /* 2 gradient */;
 }
 
     return qMax(option.fontMetrics.height() + (iconSize / 4) * 2 + 2, iconSize + (iconSize / 4) * 2 + 2) /* 2 gradient */;
 }
index d250c42c90d585c4094b5423f0964da260bad3d9..b0777415717ade131eef82a95af9d17fad39e0e0 100644 (file)
@@ -83,7 +83,6 @@ KCategorizedView::Private::Private(KCategorizedView *listView)
     , isDragging(false)
     , dragLeftViewport(false)
     , proxyModel(0)
     , isDragging(false)
     , dragLeftViewport(false)
     , proxyModel(0)
-    , lastIndex(QModelIndex())
 {
 }
 
 {
 }
 
@@ -388,6 +387,9 @@ void KCategorizedView::Private::drawNewCategory(const QModelIndex &index,
 
 void KCategorizedView::Private::updateScrollbars()
 {
 
 void KCategorizedView::Private::updateScrollbars()
 {
+    // find the last index in the last category 
+    QModelIndex lastIndex = categoriesIndexes.isEmpty() ? QModelIndex() : categoriesIndexes[categories.last()].last(); 
+
     int lastItemBottom = cachedRectIndex(lastIndex).top() +
                          listView->spacing() + (listView->gridSize().isEmpty() ? 0 : listView->gridSize().height()) - listView->viewport()->height();
 
     int lastItemBottom = cachedRectIndex(lastIndex).top() +
                          listView->spacing() + (listView->gridSize().isEmpty() ? 0 : listView->gridSize().height()) - listView->viewport()->height();
 
@@ -1243,8 +1245,6 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
         qStableSort(indexList.begin(), indexList.end(), categoryLessThan);
     }
 
         qStableSort(indexList.begin(), indexList.end(), categoryLessThan);
     }
 
-    d->lastIndex = d->categoriesIndexes[d->categories[d->categories.count() - 1]][d->categoriesIndexes[d->categories[d->categories.count() - 1]].count() - 1];
-
     // Finally, fill data information of items situation. This will help when
     // trying to compute an item place in the viewport
     int i = 0; // position relative to the category beginning
     // Finally, fill data information of items situation. This will help when
     // trying to compute an item place in the viewport
     int i = 0; // position relative to the category beginning
index 45d89aa2105f7eb7c509dc257803ccc81907b25d..1a8a7f3768a103baadc364d15e2d6caaac717943 100644 (file)
@@ -154,7 +154,6 @@ public:
     // Attributes for speed reasons
     KSortFilterProxyModel *proxyModel;
     QModelIndexList sourceModelIndexList;                // in source model
     // Attributes for speed reasons
     KSortFilterProxyModel *proxyModel;
     QModelIndexList sourceModelIndexList;                // in source model
-    QModelIndex lastIndex;
 };
 
 #endif // KCATEGORIZEDVIEW_P_H
 };
 
 #endif // KCATEGORIZEDVIEW_P_H