@@ -32,18 +32,14 @@
3232
3333using namespace unity::shell::notifications;
3434
35−struct MockNotificationModelPrivate {
36− QList<QSharedPointer<MockNotification> > queue;
37−};
38−
39−MockNotificationModel::MockNotificationModel(QObject *parent) : QAbstractListModel(parent), p(new MockNotificationModelPrivate) {
35+MockNotificationModel::MockNotificationModel(QObject *parent) : QAbstractListModel(parent) {
4036}
4137
4238MockNotificationModel::~MockNotificationModel() {
4339}
4440
4541int MockNotificationModel::rowCount(const QModelIndex &parent) const {
46− return p->queue.size();
42+ return m_queue.size();
4743}
4844
4945QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
@@ -53,69 +49,67 @@ QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
5349
5450 switch(role) {
5551 case ModelInterface::RoleType:
56− return QVariant(p->queue[index.row()]->getType());
52+ return QVariant(m_queue[index.row()]->getType());
5753
5854 case ModelInterface::RoleId:
59− return QVariant(p->queue[index.row()]->getID());
55+ return QVariant(m_queue[index.row()]->getID());
6056
6157 case ModelInterface::RoleSummary:
62− return QVariant(p->queue[index.row()]->getSummary());
58+ return QVariant(m_queue[index.row()]->getSummary());
6359
6460 case ModelInterface::RoleBody:
65− return QVariant(p->queue[index.row()]->getBody());
61+ return QVariant(m_queue[index.row()]->getBody());
6662
6763 case ModelInterface::RoleValue:
68− return QVariant(p->queue[index.row()]->getValue());
64+ return QVariant(m_queue[index.row()]->getValue());
6965
7066 case ModelInterface::RoleIcon:
71− return QVariant(p->queue[index.row()]->getIcon());
67+ return QVariant(m_queue[index.row()]->getIcon());
7268
7369 case ModelInterface::RoleSecondaryIcon:
74− return QVariant(p->queue[index.row()]->getSecondaryIcon());
70+ return QVariant(m_queue[index.row()]->getSecondaryIcon());
7571
7672 case ModelInterface::RoleActions:
77− return QVariant::fromValue(p->queue[index.row()]->getActions());
73+ return QVariant::fromValue(m_queue[index.row()]->getActions());
7874
7975 case ModelInterface::RoleHints:
80− return QVariant(p->queue[index.row()]->getHints());
76+ return QVariant(m_queue[index.row()]->getHints());
8177
8278 case ModelInterface::RoleNotification:
83− return QVariant(p->queue[index.row()]);
79+ return QVariant(m_queue[index.row()]);
8480
8581 default:
8682 return QVariant();
8783 }
8884}
8985
90−void MockNotificationModel::append(const QSharedPointer<MockNotification> &n) {
91− int location = p->queue.size();
86+void MockNotificationModel::append(MockNotification* n) {
87+ int location = m_queue.size();
9288 QModelIndex insertionPoint = QModelIndex();
9389 beginInsertRows(insertionPoint, location, location);
94− p->queue.insert(location, n);
90+ m_queue.insert(location, QSharedPointer<MockNotification>(n));
9591 endInsertRows();
96− qDebug() << "queue-size:" << p->queue.size();
92+ qDebug() << "queue-size:" << m_queue.size();
9793}
9894
99−QSharedPointer<MockNotification> MockNotificationModel::getNotification(unsigned int id) const {
100− for(int i=0; i<p->queue.size(); i++) {
101− if(p->queue[i]->getID() == id) {
102− return p->queue[i];
95+MockNotification* MockNotificationModel::getNotification(unsigned int id) const {
96+ for(int i=0; i < m_queue.size(); i++) {
97+ if(m_queue[i]->getID() == id) {
98+ return m_queue[i];
10399 }
104100 }
105101
106− QSharedPointer<MockNotification> empty;
107− return empty;
102+ return nullptr;
108103}
109104
110−QSharedPointer<MockNotification> MockNotificationModel::getNotification(const QString &summary) const {
111− for(int i=0; i<p->queue.size(); i++) {
112− if(p->queue[i]->getSummary() == summary) {
113− return p->queue[i];
105+MockNotification* MockNotificationModel::getNotification(const QString &summary) const {
106+ for(int i=0; i < m_queue.size(); i++) {
107+ if(m_queue[i]->getSummary() == summary) {
108+ return m_queue[i];
114109 }
115110 }
116111
117− QSharedPointer<MockNotification> empty;
118− return empty;
112+ return nullptr;
119113}
120114
121115bool MockNotificationModel::hasNotification(unsigned int id) const {
@@ -123,8 +117,8 @@ bool MockNotificationModel::hasNotification(unsigned int id) const {
123117}
124118
125119void MockNotificationModel::removeNotification(const unsigned int id) {
126− for(int i=0; i<p->queue.size(); i++) {
127− if(p->queue[i]->getID() == id) {
120+ for(int i = 0; i < m_queue.size(); i++) {
121+ if(m_queue[i]->getID() == id) {
128122 deleteFromVisible(i);
129123 return;
130124 }
@@ -133,7 +127,7 @@ void MockNotificationModel::removeNotification(const unsigned int id) {
133127}
134128
135129void MockNotificationModel::deleteFirst() {
136− if(p->queue.empty())
130+ if(m_queue.empty())
137131 return;
138132 deleteFromVisible(0);
139133}
@@ -141,16 +135,15 @@ void MockNotificationModel::deleteFirst() {
141135void MockNotificationModel::deleteFromVisible(int loc) {
142136 QModelIndex deletePoint = QModelIndex();
143137 beginRemoveRows(deletePoint, loc, loc);
144− p->queue.erase(p->queue.begin() + loc);
138+ m_queue.erase(m_queue.begin() + loc);
145139 endRemoveRows();
146140}
147141
148142MockNotification* MockNotificationModel::getRaw(const unsigned int notificationId) const {
149143 qDebug() << "::getRaw()";
150− for(int i=0; i<p->queue.size(); i++) {
151− if(p->queue[i]->getID() == notificationId) {
152− MockNotification* n = p->queue[i].data();
153− //QQmlEngine::setObjectOwnership(n, QQmlEngine::CppOwnership);
144+ for(int i = 0; i < m_queue.size(); i++) {
145+ if(m_queue[i]->getID() == notificationId) {
146+ MockNotification* n = m_queue[i];
154147 return n;
155148 }
156149 }
@@ -159,7 +152,7 @@ MockNotification* MockNotificationModel::getRaw(const unsigned int notificationI
159152}
160153
161154int MockNotificationModel::queued() const {
162− return p->queue.size();
155+ return m_queue.size();
163156}
164157
165158QHash<int, QByteArray> MockNotificationModel::roleNames() const {
@@ -181,8 +174,8 @@ QHash<int, QByteArray> MockNotificationModel::roleNames() const {
181174}
182175
183176void MockNotificationModel::onDataChanged(unsigned int id) {
184− for(int i=0; i<p->queue.size(); i++) {
185− if(p->queue[i]->getID() == id) {
177+ for(int i = 0; i < m_queue.size(); i++) {
178+ if(m_queue[i]->getID() == id) {
186179 Q_EMIT dataChanged(index(i, 0), index(i, 0));
187180 break;
188181 }