77#include < QTimerEvent>
88#include < QLoggingCategory>
99
10+ #include " dataaccessorproxy.h"
11+ #include " notifyaccessor.h"
1012#include " notifyentity.h"
1113#include " notifyitem.h"
12- #include " notifyaccessor.h"
13- #include " dbaccessor.h"
1414#include " notifysetting.h"
1515
1616namespace notification {
@@ -20,7 +20,7 @@ namespace notifycenter {
2020
2121NotifyStagingModel::NotifyStagingModel (QObject *parent)
2222 : QAbstractListModel(parent)
23- , m_accessor(DBAccessor ::instance())
23+ , m_accessor(DataAccessorProxy ::instance())
2424{
2525 connect (NotifyAccessor::instance (), &NotifyAccessor::stagingEntityReceived, this , &NotifyStagingModel::doEntityReceived);
2626 connect (NotifyAccessor::instance (), &NotifyAccessor::stagingEntityClosed, this , &NotifyStagingModel::onEntityClosed);
@@ -142,9 +142,9 @@ void NotifyStagingModel::remove(qint64 id)
142142 newEntity = newEntities.first ();
143143 }
144144
145- qDebug (notifyLog) << " Insert notify" << newEntity.id ();
145+ qDebug (notifyLog) << " Insert notify" << newEntity.bubbleId ();
146146 beginInsertRows (QModelIndex (), insertedIndex, insertedIndex);
147- auto notify = new AppNotifyItem (newEntity);
147+ auto notify = new BubbleNotifyItem (newEntity);
148148 m_appNotifies.insert (insertedIndex, notify);
149149 endInsertRows ();
150150 }
@@ -166,7 +166,7 @@ void NotifyStagingModel::open()
166166
167167 const auto count = std::min (static_cast <int >(entities.size ()), BubbleMaxCount);
168168 for (int i = 0 ; i < count; i++) {
169- auto notify = new AppNotifyItem (entities.at (i));
169+ auto notify = new BubbleNotifyItem (entities.at (i));
170170 m_appNotifies << notify;
171171 }
172172 updateOverlapCount (entities.size ());
@@ -246,7 +246,7 @@ void NotifyStagingModel::replace(const NotifyEntity &entity)
246246{
247247 for (int i = 0 ; i < m_appNotifies.size (); i++) {
248248 auto item = m_appNotifies[i];
249- if (item->entity (). id () == entity.id ()) {
249+ if (item->id () == entity.bubbleId ()) {
250250 item->setEntity (entity);
251251 const auto index = this ->index (i, 0 , {});
252252 dataChanged (index, index);
@@ -309,6 +309,10 @@ void NotifyStagingModel::doEntityReceived(qint64 id)
309309
310310void NotifyStagingModel::onEntityClosed (qint64 id)
311311{
312+ auto entity = m_accessor->fetchEntity (id);
313+ if (!entity.isValid ())
314+ return ;
315+ id = entity.bubbleId ();
312316 remove (id);
313317}
314318
0 commit comments