diff options
| author | Tirtha Chatterjee <[email protected]> | 2011-08-29 04:12:05 +0530 |
|---|---|---|
| committer | Tirtha Chatterjee <[email protected]> | 2011-08-29 04:12:05 +0530 |
| commit | afca8efa2601d9566c8d34d7b67dfb5abc729956 (patch) | |
| tree | 8ecd46cfe49bcde18e11e1f8056844022cb9935d /src/kitemviews/kfileitemmodel.cpp | |
| parent | b01c73607be9974032a15a4b8ab39d5379991cb6 (diff) | |
Added support for highlighting items by typing their name on the keyboard.
Diffstat (limited to 'src/kitemviews/kfileitemmodel.cpp')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index f36ab8380..c2f49f705 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -124,6 +124,24 @@ bool KFileItemModel::setData(int index, const QHash<QByteArray, QVariant>& 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; |
