Merge lp:~renatofilho/history-service/export-qml-sortproxymodel into lp:history-service

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 161
Merged at revision: 162
Proposed branch: lp:~renatofilho/history-service/export-qml-sortproxymodel
Merge into: lp:history-service
Diff against target: 63 lines (+23/-0)
2 files modified
Ubuntu/History/sortproxymodel.cpp (+19/-0)
Ubuntu/History/sortproxymodel.h (+4/-0)
To merge this branch: bzr merge lp:~renatofilho/history-service/export-qml-sortproxymodel
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+229802@code.launchpad.net

Commit message

Added "count" property for sortproxymodel;
Added "get" function for sortproxymodel;

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

Are there any related MPs required for this MP to build/function as expected? NO

Is your branch in sync with latest trunk? YES

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator? YES

Did you successfully run all tests found in your component's Test Plan on device or emulator? YES

If you changed the UI, was the change specified/approved by design? NO UI

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP? NO PACKAGE

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
Yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

Code looks good and works as expected!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Ubuntu/History/sortproxymodel.cpp'
2--- Ubuntu/History/sortproxymodel.cpp 2013-07-23 22:58:42 +0000
3+++ Ubuntu/History/sortproxymodel.cpp 2014-08-06 14:36:58 +0000
4@@ -27,6 +27,10 @@
5 {
6 setDynamicSortFilter(true);
7 updateSorting();
8+
9+ connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(countChanged()));
10+ connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(countChanged()));
11+ connect(this, SIGNAL(modelReset()), SIGNAL(countChanged()));
12 }
13
14 bool SortProxyModel::ascending() const
15@@ -43,6 +47,21 @@
16 }
17 }
18
19+QVariant SortProxyModel::get(int row) const
20+{
21+ QVariantMap data;
22+ QModelIndex sourceIndex = mapToSource(index(row, 0));
23+ if (sourceIndex.isValid()) {
24+ QAbstractItemModel *source = sourceModel();
25+ QHash<int, QByteArray> roles = source->roleNames();
26+ Q_FOREACH(int role, roles.keys()) {
27+ data.insert(roles[role], source->data(sourceIndex, role));
28+ }
29+ }
30+
31+ return data;
32+}
33+
34 void SortProxyModel::updateSorting()
35 {
36 sort(0, mAscending ? Qt::AscendingOrder : Qt::DescendingOrder);
37
38=== modified file 'Ubuntu/History/sortproxymodel.h'
39--- Ubuntu/History/sortproxymodel.h 2013-07-24 12:07:07 +0000
40+++ Ubuntu/History/sortproxymodel.h 2014-08-06 14:36:58 +0000
41@@ -31,6 +31,7 @@
42 READ ascending
43 WRITE setAscending
44 NOTIFY ascendingChanged)
45+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
46
47 public:
48 explicit SortProxyModel(QObject *parent = 0);
49@@ -38,11 +39,14 @@
50 bool ascending() const;
51 void setAscending(bool value);
52
53+ Q_INVOKABLE QVariant get(int row) const;
54+
55 private Q_SLOTS:
56 void updateSorting();
57
58 Q_SIGNALS:
59 void ascendingChanged();
60+ void countChanged();
61
62 private:
63 bool mAscending;

Subscribers

People subscribed via source and target branches