diff options
author | Anselmo L. S. Melo <[email protected]> | 2014-03-29 18:31:57 -0300 |
---|---|---|
committer | Anselmo L. S. Melo <[email protected]> | 2014-05-09 13:04:53 +0200 |
commit | 5a530b2b9e514a83b9e5f2a66f06b37d35cac3f2 (patch) | |
tree | 7d782a5a1e5e1b1afe2cf16fa4c546c6af6eedd2 /src/models | |
parent | 67d58739f5e2fbefd45ff911da244aa4c910529d (diff) |
This project was developed before the release of Qt 5.0, so some
of the APIs had to be updated in order to build again.
Change-Id: I579d7170ea0d80bd33aee29ec807461af603b0d3
Reviewed-by: Anselmo L. S. Melo <[email protected]>
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/uifilesystemmodel.cpp | 7 | ||||
-rw-r--r-- | src/models/uifilesystemmodel.h | 2 | ||||
-rw-r--r-- | src/models/uiproxyqmlmodel.cpp | 22 | ||||
-rw-r--r-- | src/models/uiproxyqmlmodel.h | 6 |
4 files changed, 21 insertions, 16 deletions
diff --git a/src/models/uifilesystemmodel.cpp b/src/models/uifilesystemmodel.cpp index e8c23c8..f437dfd 100644 --- a/src/models/uifilesystemmodel.cpp +++ b/src/models/uifilesystemmodel.cpp @@ -1860,12 +1860,15 @@ void UiFileSystemModelPrivate::init() q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)), q, SIGNAL(directoryLoaded(QString))); q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); +} - QHash<int, QByteArray> roles = q->roleNames(); +QHash<int, QByteArray> UiFileSystemModel::roleNames() const +{ + QHash<int, QByteArray> roles; roles.insert(UiFileSystemModel::FilePathRole, "filePath"); roles.insert(UiFileSystemModel::FileNameRole, "fileName"); roles.insert(UiFileSystemModel::FilePermissions, "filePermissions"); - q->setRoleNames(roles); + return roles; } /*! diff --git a/src/models/uifilesystemmodel.h b/src/models/uifilesystemmodel.h index 4279c20..61ca922 100644 --- a/src/models/uifilesystemmodel.h +++ b/src/models/uifilesystemmodel.h @@ -138,7 +138,7 @@ public: QFile::Permissions permissions(const QModelIndex &index) const; inline QFileInfo fileInfo(const QModelIndex &index) const; bool remove(const QModelIndex &index) const; - + QHash<int, QByteArray> roleNames() const; protected: UiFileSystemModel(UiFileSystemModelPrivate &, QObject *parent = 0); void timerEvent(QTimerEvent *event); diff --git a/src/models/uiproxyqmlmodel.cpp b/src/models/uiproxyqmlmodel.cpp index 47f079c..37e6f55 100644 --- a/src/models/uiproxyqmlmodel.cpp +++ b/src/models/uiproxyqmlmodel.cpp @@ -42,7 +42,8 @@ #ifndef QT_NO_PROXYQMLMODEL #include "uiproxyqmlmodel.h" -#include <QtQml/private/qquicklistmodel_p.h> +#include <QtQml/qqmlprivate.h> +#include <QtQml/private/qqmllistmodel_p.h> QT_BEGIN_NAMESPACE_UIHELPERS @@ -58,7 +59,7 @@ UiProxyQmlModel::ListType UiProxyQmlModel::updateSource(const QVariant &sourceMo if (sourceModel.type() == QVariant::List) { createFromList(sourceModel.toList()); return ArrayList; - } else if (QQuickListModel *list = qvariant_cast<QQuickListModel*>(sourceModel)) { + } else if (QQmlListModel *list = qvariant_cast<QQmlListModel*>(sourceModel)) { createFromQuickList(list); return QuickList; } @@ -66,13 +67,16 @@ UiProxyQmlModel::ListType UiProxyQmlModel::updateSource(const QVariant &sourceMo return InvalidList; } -void UiProxyQmlModel::createFromList(const QVariantList &list) -{ - QHash<int, QByteArray> roleNames; - roleNames[Qt::DisplayRole] = "display"; - setRoleNames(roleNames); +QHash<int, QByteArray> UiProxyQmlModel::roleNames() +{ + QHash<int, QByteArray> roles; + roles.insert(Qt::DisplayRole, "display"); + return roles; +} +void UiProxyQmlModel::createFromList(const QVariantList &list) +{ foreach (const QVariant& var, list) { QStandardItem *item = new QStandardItem(); item->setData(var, Qt::DisplayRole); @@ -81,10 +85,8 @@ void UiProxyQmlModel::createFromList(const QVariantList &list) } } -void UiProxyQmlModel::createFromQuickList(QQuickListModel *list) +void UiProxyQmlModel::createFromQuickList(QQmlListModel *list) { - setRoleNames(list->roleNames()); - for (int i = 0; i < list->count(); i++) { QStandardItem *item = new QStandardItem(); diff --git a/src/models/uiproxyqmlmodel.h b/src/models/uiproxyqmlmodel.h index 3b69207..2192459 100644 --- a/src/models/uiproxyqmlmodel.h +++ b/src/models/uiproxyqmlmodel.h @@ -50,7 +50,7 @@ QT_BEGIN_HEADER -class QQuickListModel; +class QQmlListModel; QT_BEGIN_NAMESPACE_UIHELPERS @@ -66,10 +66,10 @@ public: UiProxyQmlModel(QObject *parent = 0); ListType updateSource(const QVariant &sourceModel); - + QHash<int, QByteArray> roleNames(); protected: void createFromList(const QVariantList &list); - void createFromQuickList(QQuickListModel *list); + void createFromQuickList(QQmlListModel *list); }; QT_END_NAMESPACE_UIHELPERS |