Merge lp:~aacid/unity-notifications/placeholderbeginning into lp:unity-notifications

Proposed by Albert Astals Cid
Status: Merged
Approved by: Michał Sawicz
Approved revision: 184
Merged at revision: 183
Proposed branch: lp:~aacid/unity-notifications/placeholderbeginning
Merge into: lp:unity-notifications
Diff against target: 123 lines (+24/-18)
3 files modified
include/Notification.h (+1/-1)
src/NotificationModel.cpp (+20/-14)
test/notificationtest.cpp (+3/-3)
To merge this branch: bzr merge lp:~aacid/unity-notifications/placeholderbeginning
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot (community) continuous-integration Approve
Unity API Team Pending
Review via email: mp+191379@code.launchpad.net

Commit message

Add a placeholder at the beginning of the notification list

Description of the change

This will, in the futuer, be controlled by a boolean confirmationPlaceholder property, but for now we'll just hide it unity8-side. It helps us with a focus issue in there.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Yes, this is working.

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

This breaks the append_hint usecase :/

review: Needs Fixing
184. By Albert Astals Cid

emit the correct dataChanged

Revision history for this message
Michał Sawicz (saviq) wrote :

Yes!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/Notification.h'
2--- include/Notification.h 2013-10-14 11:51:41 +0000
3+++ include/Notification.h 2013-10-16 13:51:11 +0000
4@@ -52,7 +52,7 @@
5
6 public:
7 enum Urgency { Low, Normal, Critical };
8- enum Type { Confirmation, Ephemeral, Interactive, SnapDecision, PlaceHolder };
9+ enum Type { PlaceHolder, Confirmation, Ephemeral, Interactive, SnapDecision };
10
11 Q_SIGNALS:
12 void bodyChanged(QString text);
13
14=== modified file 'src/NotificationModel.cpp'
15--- src/NotificationModel.cpp 2013-10-14 11:51:41 +0000
16+++ src/NotificationModel.cpp 2013-10-16 13:51:11 +0000
17@@ -40,6 +40,7 @@
18 }
19
20 NotificationModel::NotificationModel(QObject *parent) : QAbstractListModel(parent), p(new NotificationModelPrivate) {
21+ p->displayedNotifications.append(QSharedPointer<Notification>(new Notification(0, -1, Notification::Normal, QString(), Notification::PlaceHolder)));
22 connect(&(p->timer), SIGNAL(timeout()), this, SLOT(timeout()));
23 p->timer.setSingleShot(true);
24 }
25@@ -60,7 +61,7 @@
26 }
27
28 int NotificationModel::rowCount(const QModelIndex &parent) const {
29- //printf("Count %d\n", displayedNotifications.size());
30+ //printf("Count %d\n", p->displayedNotifications.size());
31 return p->displayedNotifications.size();
32 }
33
34@@ -294,7 +295,8 @@
35 for(int i=p->displayedNotifications.size()-1; i>=0; i--) {
36 QSharedPointer<Notification> n = p->displayedNotifications[i];
37 int shownTime = p->displayTimes[n->getID()];
38- if(shownTime >= n->getDisplayTime()) {
39+ int totalTime = n->getDisplayTime();
40+ if(totalTime >= 0 && shownTime >= totalTime) {
41 deleteFromVisible(i);
42 }
43 }
44@@ -323,12 +325,14 @@
45 for(int i=0; i<p->displayedNotifications.size(); i++) {
46 QSharedPointer<Notification> n = p->displayedNotifications[i];
47 int totalTime = n->getDisplayTime();
48- int shownTime = p->displayTimes[n->getID()];
49- int remainingTime = totalTime - shownTime;
50- if(remainingTime < 0)
51- remainingTime = 0;
52- if(remainingTime < mintime)
53- mintime = remainingTime;
54+ if (totalTime >= 0) {
55+ int shownTime = p->displayTimes[n->getID()];
56+ int remainingTime = totalTime - shownTime;
57+ if(remainingTime < 0)
58+ remainingTime = 0;
59+ if(remainingTime < mintime)
60+ mintime = remainingTime;
61+ }
62 }
63 return mintime;
64 }
65@@ -422,7 +426,6 @@
66 }
67
68 int NotificationModel::insertionPoint(const QSharedPointer<Notification> n) const {
69- int i=0;
70 if(n->getType() == Notification::Type::SnapDecision) {
71 int loc = findFirst(Notification::Type::SnapDecision);
72 int numSnaps = countShowing(Notification::Type::SnapDecision);
73@@ -433,6 +436,7 @@
74 }
75 return loc+numSnaps;
76 } else {
77+ int i=0;
78 for(; i<p->displayedNotifications.size(); i++) {
79 if(p->displayedNotifications[i]->getType() > n->getType()) {
80 break;
81@@ -452,7 +456,7 @@
82 //QModelIndex insertionPoint = QAbstractItemModel::createIndex(location, 0);
83 //beginInsertRows(insertionPoint, location, location);
84 QModelIndex insertionPoint = QModelIndex();
85- beginInsertRows(insertionPoint, rowCount(insertionPoint), rowCount(insertionPoint));
86+ beginInsertRows(insertionPoint, location, location);
87 p->displayedNotifications.insert(location, n);
88 endInsertRows();
89 p->displayTimes[n->getID()] = 0;
90@@ -546,8 +550,10 @@
91 }
92
93 void NotificationModel::onDataChanged(unsigned int id) {
94- // FIXME: not really the right way to do it by assuming
95- // it's always the first notification being displayed
96- // that's affected by a potential data-change
97- Q_EMIT dataChanged(index(0, 0), index(0, 0));
98+ for(int i=0; i<p->displayedNotifications.size(); i++) {
99+ if(p->displayedNotifications[i]->getID() == id) {
100+ Q_EMIT dataChanged(index(i, 0), index(i, 0));
101+ break;
102+ }
103+ }
104 }
105
106=== modified file 'test/notificationtest.cpp'
107--- test/notificationtest.cpp 2013-06-18 08:36:08 +0000
108+++ test/notificationtest.cpp 2013-10-16 13:51:11 +0000
109@@ -10,11 +10,11 @@
110 QSharedPointer<Notification> n(new Notification(42, timeout, Notification::Low, "this is text"));
111 NotificationModel m;
112
113- assert(m.numNotifications() == 0);
114+ assert(m.numNotifications() == 1);
115 m.insertNotification(n);
116- assert(m.numNotifications() == 1);
117+ assert(m.numNotifications() == 2);
118 m.removeNotification(n->getID());
119- assert(m.numNotifications() == 0);
120+ assert(m.numNotifications() == 1);
121 }
122
123 void testTypeSimple() {

Subscribers

People subscribed via source and target branches