From 7a91492cff931c0c4e0d38dd0aee77d9dcb29373 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sun, 4 Sep 2011 17:40:44 +0200 Subject: Improved drag and drop support --- src/kitemviews/kfileitemmodel.cpp | 42 ++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src/kitemviews/kfileitemmodel.cpp') diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 33dc9979b..401ba218d 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -123,24 +123,6 @@ bool KFileItemModel::setData(int index, const QHash& value return false; } -int KFileItemModel::indexForKeyboardSearch(const QString& text, int startFromIndex) const -{ - startFromIndex = qMax(0, startFromIndex); - for (int i = startFromIndex; i < count(); i++) { - if (data(i)["name"].toString().startsWith(text, Qt::CaseInsensitive)) { - kDebug() << data(i)["name"].toString(); - return i; - } - } - for (int i = 0; i < startFromIndex; i++) { - if (data(i)["name"].toString().startsWith(text, Qt::CaseInsensitive)) { - kDebug() << data(i)["name"].toString(); - return i; - } - } - return -1; -} - bool KFileItemModel::supportsGrouping() const { return true; @@ -189,6 +171,30 @@ QMimeData* KFileItemModel::createMimeData(const QSet& indexes) const return data; } +int KFileItemModel::indexForKeyboardSearch(const QString& text, int startFromIndex) const +{ + startFromIndex = qMax(0, startFromIndex); + for (int i = startFromIndex; i < count(); i++) { + if (data(i)["name"].toString().startsWith(text, Qt::CaseInsensitive)) { + kDebug() << data(i)["name"].toString(); + return i; + } + } + for (int i = 0; i < startFromIndex; i++) { + if (data(i)["name"].toString().startsWith(text, Qt::CaseInsensitive)) { + kDebug() << data(i)["name"].toString(); + return i; + } + } + return -1; +} + +bool KFileItemModel::supportsDropping(int index) const +{ + const KFileItem item = fileItem(index); + return item.isNull() ? false : item.isDir(); +} + KFileItem KFileItemModel::fileItem(int index) const { if (index >= 0 && index < count()) { -- cgit v1.3