@@ -32,18 +32,14 @@
33using namespace unity::shell::notifications;
33using namespace unity::shell::notifications;
35−struct MockNotificationModelPrivate {
36− QList<QSharedPointer<MockNotification> > queue;
39−MockNotificationModel::MockNotificationModel(QObject *parent) : QAbstractListModel(parent), p(new MockNotificationModelPrivate) {
35+MockNotificationModel::MockNotificationModel(QObject *parent) : QAbstractListModel(parent) {
42MockNotificationModel::~MockNotificationModel() {
38MockNotificationModel::~MockNotificationModel() {
45int MockNotificationModel::rowCount(const QModelIndex &parent) const {
41int MockNotificationModel::rowCount(const QModelIndex &parent) const {
46− return p->queue.size();
42+ return m_queue.size();
49QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
45QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
@@ -53,69 +49,67 @@ QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
54 switch(role) {
50 switch(role) {
55 case ModelInterface::RoleType:
51 case ModelInterface::RoleType:
56− return QVariant(p->queue[index.row()]->getType());
52+ return QVariant(m_queue[index.row()]->getType());
58 case ModelInterface::RoleId:
54 case ModelInterface::RoleId:
59− return QVariant(p->queue[index.row()]->getID());
55+ return QVariant(m_queue[index.row()]->getID());
61 case ModelInterface::RoleSummary:
57 case ModelInterface::RoleSummary:
62− return QVariant(p->queue[index.row()]->getSummary());
58+ return QVariant(m_queue[index.row()]->getSummary());
64 case ModelInterface::RoleBody:
60 case ModelInterface::RoleBody:
65− return QVariant(p->queue[index.row()]->getBody());
61+ return QVariant(m_queue[index.row()]->getBody());
67 case ModelInterface::RoleValue:
63 case ModelInterface::RoleValue:
68− return QVariant(p->queue[index.row()]->getValue());
64+ return QVariant(m_queue[index.row()]->getValue());
70 case ModelInterface::RoleIcon:
66 case ModelInterface::RoleIcon:
71− return QVariant(p->queue[index.row()]->getIcon());
67+ return QVariant(m_queue[index.row()]->getIcon());
73 case ModelInterface::RoleSecondaryIcon:
69 case ModelInterface::RoleSecondaryIcon:
74− return QVariant(p->queue[index.row()]->getSecondaryIcon());
70+ return QVariant(m_queue[index.row()]->getSecondaryIcon());
76 case ModelInterface::RoleActions:
72 case ModelInterface::RoleActions:
77− return QVariant::fromValue(p->queue[index.row()]->getActions());
73+ return QVariant::fromValue(m_queue[index.row()]->getActions());
79 case ModelInterface::RoleHints:
75 case ModelInterface::RoleHints:
80− return QVariant(p->queue[index.row()]->getHints());
76+ return QVariant(m_queue[index.row()]->getHints());
82 case ModelInterface::RoleNotification:
78 case ModelInterface::RoleNotification:
83− return QVariant(p->queue[index.row()]);
79+ return QVariant(m_queue[index.row()]);
86 return QVariant();
82 return QVariant();
90−void MockNotificationModel::append(const QSharedPointer<MockNotification> &n) {
86+void MockNotificationModel::append(MockNotification* n) {
91− int location = p->queue.size();
87+ int location = m_queue.size();
92 QModelIndex insertionPoint = QModelIndex();
88 QModelIndex insertionPoint = QModelIndex();
93 beginInsertRows(insertionPoint, location, location);
89 beginInsertRows(insertionPoint, location, location);
94− p->queue.insert(location, n);
90+ m_queue.insert(location, QSharedPointer<MockNotification>(n));
95 endInsertRows();
91 endInsertRows();
96− qDebug() << "queue-size:" << p->queue.size();
92+ qDebug() << "queue-size:" << m_queue.size();
99−QSharedPointer<MockNotification> MockNotificationModel::getNotification(unsigned int id) const {
95+MockNotification* MockNotificationModel::getNotification(unsigned int id) const {
100− for(int i=0; i<p->queue.size(); i++) {
96+ for(int i=0; i < m_queue.size(); i++) {
101− if(p->queue[i]->getID() == id) {
97+ if(m_queue[i]->getID() == id) {
102− return p->queue[i];
98+ return m_queue[i];
106− QSharedPointer<MockNotification> empty;
107− return empty;
102+ return nullptr;
110−QSharedPointer<MockNotification> MockNotificationModel::getNotification(const QString &summary) const {
105+MockNotification* MockNotificationModel::getNotification(const QString &summary) const {
111− for(int i=0; i<p->queue.size(); i++) {
106+ for(int i=0; i < m_queue.size(); i++) {
112− if(p->queue[i]->getSummary() == summary) {
107+ if(m_queue[i]->getSummary() == summary) {
113− return p->queue[i];
108+ return m_queue[i];
117− QSharedPointer<MockNotification> empty;
118− return empty;
112+ return nullptr;
121bool MockNotificationModel::hasNotification(unsigned int id) const {
115bool MockNotificationModel::hasNotification(unsigned int id) const {
@@ -123,8 +117,8 @@ bool MockNotificationModel::hasNotification(unsigned int id) const {
125void MockNotificationModel::removeNotification(const unsigned int id) {
119void MockNotificationModel::removeNotification(const unsigned int id) {
126− for(int i=0; i<p->queue.size(); i++) {
120+ for(int i = 0; i < m_queue.size(); i++) {
127− if(p->queue[i]->getID() == id) {
121+ if(m_queue[i]->getID() == id) {
128 deleteFromVisible(i);
122 deleteFromVisible(i);
@@ -133,7 +127,7 @@ void MockNotificationModel::removeNotification(const unsigned int id) {
135void MockNotificationModel::deleteFirst() {
129void MockNotificationModel::deleteFirst() {
136− if(p->queue.empty())
130+ if(m_queue.empty())
138 deleteFromVisible(0);
132 deleteFromVisible(0);
@@ -141,16 +135,15 @@ void MockNotificationModel::deleteFirst() {
141void MockNotificationModel::deleteFromVisible(int loc) {
135void MockNotificationModel::deleteFromVisible(int loc) {
142 QModelIndex deletePoint = QModelIndex();
136 QModelIndex deletePoint = QModelIndex();
143 beginRemoveRows(deletePoint, loc, loc);
137 beginRemoveRows(deletePoint, loc, loc);
144− p->queue.erase(p->queue.begin() + loc);
138+ m_queue.erase(m_queue.begin() + loc);
145 endRemoveRows();
139 endRemoveRows();
148MockNotification* MockNotificationModel::getRaw(const unsigned int notificationId) const {
142MockNotification* MockNotificationModel::getRaw(const unsigned int notificationId) const {
149 qDebug() << "::getRaw()";
143 qDebug() << "::getRaw()";
150− for(int i=0; i<p->queue.size(); i++) {
144+ for(int i = 0; i < m_queue.size(); i++) {
151− if(p->queue[i]->getID() == notificationId) {
145+ if(m_queue[i]->getID() == notificationId) {
152− MockNotification* n = p->queue[i].data();
146+ MockNotification* n = m_queue[i];
153− //QQmlEngine::setObjectOwnership(n, QQmlEngine::CppOwnership);
154 return n;
147 return n;
@@ -159,7 +152,7 @@ MockNotification* MockNotificationModel::getRaw(const unsigned int notificationI
161int MockNotificationModel::queued() const {
154int MockNotificationModel::queued() const {
162− return p->queue.size();
155+ return m_queue.size();
165QHash<int, QByteArray> MockNotificationModel::roleNames() const {
158QHash<int, QByteArray> MockNotificationModel::roleNames() const {
@@ -181,8 +174,8 @@ QHash<int, QByteArray> MockNotificationModel::roleNames() const {
183void MockNotificationModel::onDataChanged(unsigned int id) {
176void MockNotificationModel::onDataChanged(unsigned int id) {
184− for(int i=0; i<p->queue.size(); i++) {
177+ for(int i = 0; i < m_queue.size(); i++) {
185− if(p->queue[i]->getID() == id) {
178+ if(m_queue[i]->getID() == id) {
186 Q_EMIT dataChanged(index(i, 0), index(i, 0));
179 Q_EMIT dataChanged(index(i, 0), index(i, 0));