Merge lp:~mihirsoni/telegram-app/addedGetFunction into lp:telegram-app/dev

Proposed by Mihir Soni
Status: Merged
Approved by: Michał Karnicki
Approved revision: 79
Merged at revision: 80
Proposed branch: lp:~mihirsoni/telegram-app/addedGetFunction
Merge into: lp:telegram-app/dev
Diff against target: 51 lines (+16/-0)
2 files modified
qmlplugin/models/sortproxymodel.cpp (+13/-0)
qmlplugin/models/sortproxymodel.h (+3/-0)
To merge this branch: bzr merge lp:~mihirsoni/telegram-app/addedGetFunction
Reviewer Review Type Date Requested Status
Michał Karnicki (community) Approve
Review via email: mp+237492@code.launchpad.net

Commit message

- Added getFunction in SortProxyModel to get data based on index.

Description of the change

- Added getFunction in SortProxyModel to get data based on index.

To post a comment you must log in.
Revision history for this message
Michał Karnicki (karni) :
review: Needs Information
77. By Mihir Soni

addressed review comments

78. By Mihir Soni

resolve typo

79. By Mihir Soni

appropriate var names

Revision history for this message
Michał Karnicki (karni) wrote :

This looks good. I'd like to top-approve once the QML counterpart is ready to test this with :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qmlplugin/models/sortproxymodel.cpp'
2--- qmlplugin/models/sortproxymodel.cpp 2014-09-12 08:15:27 +0000
3+++ qmlplugin/models/sortproxymodel.cpp 2014-10-08 18:22:28 +0000
4@@ -59,6 +59,19 @@
5 }
6 }
7
8+QVariant SortProxyModel::get(int rowIndex) const {
9+ QVariantMap data;
10+ QModelIndex sourceIndex = mapToSource(index(rowIndex, 0));
11+ if (sourceIndex.isValid()) {
12+ QAbstractItemModel *source = sourceModel();
13+ QHash<int, QByteArray> roles = source->roleNames();
14+ Q_FOREACH(int role, roles.keys()) {
15+ data.insert(roles[role], source->data(sourceIndex, role));
16+ }
17+ }
18+ return data;
19+}
20+
21 void SortProxyModel::updateSorting()
22 {
23 sort(0, mAscending ? Qt::AscendingOrder : Qt::DescendingOrder);
24
25=== modified file 'qmlplugin/models/sortproxymodel.h'
26--- qmlplugin/models/sortproxymodel.h 2014-08-13 20:17:27 +0000
27+++ qmlplugin/models/sortproxymodel.h 2014-10-08 18:22:28 +0000
28@@ -28,6 +28,7 @@
29 {
30 Q_OBJECT
31 Q_PROPERTY(bool ascending READ ascending WRITE setAscending NOTIFY ascendingChanged)
32+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
33 Q_PROPERTY(QString searchTerm READ searchTerm WRITE setSearchTerm NOTIFY searchTermChanged)
34
35 public:
36@@ -35,6 +36,7 @@
37
38 bool ascending() const;
39 void setAscending(bool value);
40+ Q_INVOKABLE QVariant get(int rowIndex) const;
41
42 QString searchTerm() const;
43 void setSearchTerm(QString searchTerm);
44@@ -45,6 +47,7 @@
45 Q_SIGNALS:
46 void ascendingChanged();
47 void searchTermChanged();
48+ void countChanged();
49
50 private:
51 bool mAscending;

Subscribers

People subscribed via source and target branches

to all changes: