diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-12-16 05:09:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-12-16 05:09:20 (GMT) |
commit | b9d7f819b7bf9f7c39735377ae2e3e4d4afa1cf7 (patch) | |
tree | e02c4575aa1a1e865dffbe6095449da50f7cb5b0 /tools/qmlviewer | |
parent | 91fe11aeecc951c0713f7275726081017c385495 (diff) | |
download | Qt-b9d7f819b7bf9f7c39735377ae2e3e4d4afa1cf7.zip Qt-b9d7f819b7bf9f7c39735377ae2e3e4d4afa1cf7.tar.gz Qt-b9d7f819b7bf9f7c39735377ae2e3e4d4afa1cf7.tar.bz2 |
Make QListModelInterface API more sensible for our use case.
Diffstat (limited to 'tools/qmlviewer')
-rw-r--r-- | tools/qmlviewer/qmlfolderlistmodel.cpp | 14 | ||||
-rw-r--r-- | tools/qmlviewer/qmlfolderlistmodel.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tools/qmlviewer/qmlfolderlistmodel.cpp b/tools/qmlviewer/qmlfolderlistmodel.cpp index 4f33f31..35c672d 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.cpp +++ b/tools/qmlviewer/qmlfolderlistmodel.cpp @@ -142,6 +142,20 @@ QHash<int,QVariant> QmlFolderListModel::data(int index, const QList<int> &roles) return folderData; } +QVariant QmlFolderListModel::data(int index, int role) const +{ + QVariant rv; + QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex); + if (modelIndex.isValid()) { + if (role == QDirModel::FileNameRole) + rv = d->model.data(modelIndex, QDirModel::FileNameRole); + else if (role == QDirModel::FilePathRole) + rv = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString()); + } + + return rv; +} + int QmlFolderListModel::count() const { return d->count; diff --git a/tools/qmlviewer/qmlfolderlistmodel.h b/tools/qmlviewer/qmlfolderlistmodel.h index cbee8c7..7357954 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.h +++ b/tools/qmlviewer/qmlfolderlistmodel.h @@ -68,6 +68,7 @@ public: ~QmlFolderListModel(); virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const; + virtual QVariant data(int index, int role) const; virtual int count() const; virtual QList<int> roles() const; virtual QString toString(int role) const; |