Merge lp:~boiko/history-service/rtm-remove_multiple_entries into lp:history-service/rtm-14.09

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Bill Filler
Approved revision: 169
Merged at revision: 169
Proposed branch: lp:~boiko/history-service/rtm-remove_multiple_entries
Merge into: lp:history-service/rtm-14.09
Diff against target: 123 lines (+46/-12)
4 files modified
Ubuntu/History/historyeventmodel.cpp (+25/-4)
Ubuntu/History/historyeventmodel.h (+2/-2)
Ubuntu/History/historythreadmodel.cpp (+17/-4)
Ubuntu/History/historythreadmodel.h (+2/-2)
To merge this branch: bzr merge lp:~boiko/history-service/rtm-remove_multiple_entries
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+245944@code.launchpad.net

Commit message

Make it possible to delete multiple entries from QML.

Description of the change

Make it possible to delete multiple entries from QML.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Ubuntu/History/historyeventmodel.cpp'
2--- Ubuntu/History/historyeventmodel.cpp 2014-09-24 20:10:24 +0000
3+++ Ubuntu/History/historyeventmodel.cpp 2015-01-09 12:06:16 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2013-2014 Canonical, Ltd.
7+ * Copyright (C) 2013-2015 Canonical, Ltd.
8 *
9 * Authors:
10 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
11@@ -190,10 +190,31 @@
12 return mRoles;
13 }
14
15-bool HistoryEventModel::removeEvent(const QString &accountId, const QString &threadId, const QString &eventId, int eventType)
16+bool HistoryEventModel::removeEvents(const QVariantList &eventsProperties)
17 {
18- History::Event event = History::Manager::instance()->getSingleEvent((History::EventType)eventType, accountId, threadId, eventId);
19- return History::Manager::instance()->removeEvents(History::Events() << event);
20+ History::Events events;
21+ Q_FOREACH(const QVariant &entry, eventsProperties) {
22+ QVariantMap eventProperties = entry.toMap();
23+ History::Event event;
24+ switch (eventProperties[History::FieldType].toInt()) {
25+ case History::EventTypeText:
26+ event = History::TextEvent::fromProperties(eventProperties);
27+ break;
28+ case History::EventTypeVoice:
29+ event = History::VoiceEvent::fromProperties(eventProperties);
30+ break;
31+ }
32+
33+ if (!event.isNull()) {
34+ events << event;
35+ }
36+ }
37+
38+ if (events.isEmpty()) {
39+ return false;
40+ }
41+
42+ return History::Manager::instance()->removeEvents(events);
43 }
44
45 bool HistoryEventModel::removeEventAttachment(const QString &accountId, const QString &threadId, const QString &eventId, int eventType, const QString &attachmentId)
46
47=== modified file 'Ubuntu/History/historyeventmodel.h'
48--- Ubuntu/History/historyeventmodel.h 2014-09-24 20:10:24 +0000
49+++ Ubuntu/History/historyeventmodel.h 2015-01-09 12:06:16 +0000
50@@ -1,5 +1,5 @@
51 /*
52- * Copyright (C) 2013-2014 Canonical, Ltd.
53+ * Copyright (C) 2013-2015 Canonical, Ltd.
54 *
55 * Authors:
56 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
57@@ -60,7 +60,7 @@
58
59 virtual QHash<int, QByteArray> roleNames() const;
60
61- Q_INVOKABLE bool removeEvent(const QString &accountId, const QString &threadId, const QString &eventId, int eventType);
62+ Q_INVOKABLE bool removeEvents(const QVariantList &eventsProperties);
63 Q_INVOKABLE bool markEventAsRead(const QString &accountId, const QString &threadId, const QString &eventId, int eventType);
64 Q_INVOKABLE bool removeEventAttachment(const QString &accountId, const QString &threadId, const QString &eventId, int eventType, const QString &attachmentId);
65
66
67=== modified file 'Ubuntu/History/historythreadmodel.cpp'
68--- Ubuntu/History/historythreadmodel.cpp 2014-09-09 22:56:16 +0000
69+++ Ubuntu/History/historythreadmodel.cpp 2015-01-09 12:06:16 +0000
70@@ -1,5 +1,5 @@
71 /*
72- * Copyright (C) 2013-2014 Canonical, Ltd.
73+ * Copyright (C) 2013-2015 Canonical, Ltd.
74 *
75 * Authors:
76 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
77@@ -213,10 +213,23 @@
78 return mRoles;
79 }
80
81-bool HistoryThreadModel::removeThread(const QString &accountId, const QString &threadId, int eventType)
82+bool HistoryThreadModel::removeThreads(const QVariantList &threadsProperties)
83 {
84- History::Thread thread = History::Manager::instance()->getSingleThread((History::EventType)eventType, accountId, threadId);
85- return History::Manager::instance()->removeThreads(History::Threads() << thread);
86+ History::Threads threads;
87+ Q_FOREACH(const QVariant &entry, threadsProperties) {
88+ QVariantMap threadProperties = entry.toMap();
89+ History::Thread thread = History::Thread::fromProperties(threadProperties);
90+
91+ if (!thread.isNull()) {
92+ threads << thread;
93+ }
94+ }
95+
96+ if (threads.isEmpty()) {
97+ return false;
98+ }
99+
100+ return History::Manager::instance()->removeThreads(threads);
101 }
102
103 void HistoryThreadModel::updateQuery()
104
105=== modified file 'Ubuntu/History/historythreadmodel.h'
106--- Ubuntu/History/historythreadmodel.h 2014-09-09 18:17:44 +0000
107+++ Ubuntu/History/historythreadmodel.h 2015-01-09 12:06:16 +0000
108@@ -1,5 +1,5 @@
109 /*
110- * Copyright (C) 2013-2014 Canonical, Ltd.
111+ * Copyright (C) 2013-2015 Canonical, Ltd.
112 *
113 * Authors:
114 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
115@@ -67,7 +67,7 @@
116
117 virtual QHash<int, QByteArray> roleNames() const;
118
119- Q_INVOKABLE bool removeThread(const QString &accountId, const QString &threadId, int eventType);
120+ Q_INVOKABLE bool removeThreads(const QVariantList &threadsProperties);
121
122 protected Q_SLOTS:
123 virtual void updateQuery();

Subscribers

People subscribed via source and target branches