X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e6785665752a8a3e6f9d9a73d40fdb22a2af7d04..8a08dd71cae63ce4e2df8dbf5d93b8ba0dd27340:/src/kcategorizedview.cpp diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp index b07774157..e178760ee 100644 --- a/src/kcategorizedview.cpp +++ b/src/kcategorizedview.cpp @@ -33,7 +33,7 @@ #include #include "kitemcategorizer.h" -#include "ksortfilterproxymodel.h" +#include "dolphinsortfilterproxymodel.h" class LessThan { @@ -44,7 +44,7 @@ public: CategoryPurpose }; - inline LessThan(const KSortFilterProxyModel *proxyModel, + inline LessThan(const DolphinSortFilterProxyModel *proxyModel, Purpose purpose) : proxyModel(proxyModel) , purpose(purpose) @@ -67,7 +67,7 @@ public: } private: - const KSortFilterProxyModel *proxyModel; + const DolphinSortFilterProxyModel *proxyModel; const Purpose purpose; }; @@ -485,7 +485,7 @@ void KCategorizedView::setModel(QAbstractItemModel *model) QListView::setModel(model); - d->proxyModel = dynamic_cast(model); + d->proxyModel = dynamic_cast(model); if (d->proxyModel) { @@ -1000,8 +1000,11 @@ void KCategorizedView::dragLeaveEvent(QDragLeaveEvent *event) QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) { - if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel || - !d->itemCategorizer) + if ( (viewMode() != KCategorizedView::IconMode) || + !d->proxyModel || + !d->itemCategorizer || + d->categories.isEmpty() + ) { return QListView::moveCursor(cursorAction, modifiers); } @@ -1023,9 +1026,10 @@ QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction, int itemWidthPlusSeparation = spacing() + itemWidth; int elementsPerRow = viewportWidth / itemWidthPlusSeparation; - QString lastCategory = d->categories[0]; - QString theCategory = d->categories[0]; - QString afterCategory = d->categories[0]; + QString lastCategory = d->categories.first(); + QString theCategory = d->categories.first(); + QString afterCategory = d->categories.first(); + bool hasToBreak = false; foreach (const QString &category, d->categories) {