From 215306ee13d2079bffd409a22b68b0a7e0e270bc Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 25 Nov 2011 18:47:34 +0100 Subject: [PATCH] give the default models the get(row) function some default components expect models to provide it --- declarativeimports/core/datamodel.cpp | 25 +++++++++++++++++++ declarativeimports/core/datamodel.h | 4 +++ .../touch/SectionScroller.qml | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/declarativeimports/core/datamodel.cpp b/declarativeimports/core/datamodel.cpp index 0b260af4f..e4a2e0213 100644 --- a/declarativeimports/core/datamodel.cpp +++ b/declarativeimports/core/datamodel.cpp @@ -123,6 +123,18 @@ void SortFilterModel::setSortOrder(const Qt::SortOrder order) sort(0, order); } +QVariantHash SortFilterModel::get(int row) const +{ + QModelIndex idx = index(row, 0); + QVariantHash hash; + + QHash::const_iterator i; + for (i = roleNames().constBegin(); i != roleNames().constEnd(); ++i) { + hash[i.value()] = data(idx, i.key()); + } + + return hash; +} @@ -423,6 +435,19 @@ int DataModel::columnCount(const QModelIndex &parent) const return 1; } +QVariantHash DataModel::get(int row) const +{ + QModelIndex idx = index(row, 0); + QVariantHash hash; + + QHash::const_iterator i; + for (i = roleNames().constBegin(); i != roleNames().constEnd(); ++i) { + hash[i.value()] = data(idx, i.key()); + } + + return hash; +} + int DataModel::roleNameToId(const QString &name) { if (!m_roleIds.contains(name)) { diff --git a/declarativeimports/core/datamodel.h b/declarativeimports/core/datamodel.h index 744ec9e93..719500061 100644 --- a/declarativeimports/core/datamodel.h +++ b/declarativeimports/core/datamodel.h @@ -68,6 +68,8 @@ public: int count() const {return QSortFilterProxyModel::rowCount();} + Q_INVOKABLE QVariantHash get(int i) const; + Q_SIGNALS: void countChanged(); @@ -124,6 +126,8 @@ public: int count() const {return countItems();} + Q_INVOKABLE QVariantHash get(int i) const; + protected: void setItems(const QString &sourceName, const QVariantList &list); inline int countItems() const; diff --git a/declarativeimports/plasmacomponents/platformcomponents/touch/SectionScroller.qml b/declarativeimports/plasmacomponents/platformcomponents/touch/SectionScroller.qml index 0db1406f7..17711a774 100644 --- a/declarativeimports/plasmacomponents/platformcomponents/touch/SectionScroller.qml +++ b/declarativeimports/plasmacomponents/platformcomponents/touch/SectionScroller.qml @@ -190,7 +190,7 @@ Item { MouseArea { id: dragArea anchors.fill: parent - enabled: scrollbar.enabled + //enabled: scrollbar.enabled drag { target: handle axis: Drag.YAxis