Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions panels/notification/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ target_link_libraries(ds-notification PRIVATE
add_library(ds-notification-shared SHARED
${CMAKE_SOURCE_DIR}/panels/notification/common/notifyentity.h
${CMAKE_SOURCE_DIR}/panels/notification/common/notifyentity.cpp
${CMAKE_SOURCE_DIR}/panels/notification/common/dataaccessorproxy.h
${CMAKE_SOURCE_DIR}/panels/notification/common/dataaccessorproxy.cpp
${CMAKE_SOURCE_DIR}/panels/notification/common/memoryaccessor.h
${CMAKE_SOURCE_DIR}/panels/notification/common/memoryaccessor.cpp
${CMAKE_SOURCE_DIR}/panels/notification/common/dbaccessor.h
${CMAKE_SOURCE_DIR}/panels/notification/common/dbaccessor.cpp
${CMAKE_SOURCE_DIR}/panels/notification/common/notifysetting.h
Expand Down
6 changes: 3 additions & 3 deletions panels/notification/bubble/bubblemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
return nullptr;
}
for (const auto &item : m_bubbles) {
if (item->id() == id) {
if (item->bubbleId() == id) {

Check warning on line 138 in panels/notification/bubble/bubblemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Consider using std::find_if algorithm instead of a raw loop.
m_delayBubbles.removeAll(id);
remove(m_bubbles.indexOf(item));
return item;
Expand Down Expand Up @@ -169,7 +169,7 @@
case BubbleModel::AppName:
return m_bubbles[row]->appName();
case BubbleModel::Id:
return m_bubbles[row]->id();
return m_bubbles[row]->bubbleId();
case BubbleModel::Body:
return m_bubbles[row]->body();
case BubbleModel::Summary:
Expand Down Expand Up @@ -281,7 +281,7 @@
if (item->appName() != bubble->appName())
continue;

if (item->id() == bubble->id()) {
if (item->bubbleId() == bubble->bubbleId()) {
return i;
}
}
Expand Down
11 changes: 8 additions & 3 deletions panels/notification/bubble/bubblepanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "bubblepanel.h"
#include "bubbleitem.h"
#include "bubblemodel.h"
#include "dataaccessorproxy.h"

Check warning on line 8 in panels/notification/bubble/bubblepanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dataaccessorproxy.h" not found.
#include "pluginfactory.h"

Check warning on line 9 in panels/notification/bubble/bubblepanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "pluginfactory.h" not found.
#include "bubbleitem.h"
#include "dbaccessor.h"

#include <QLoggingCategory>

Check warning on line 11 in panels/notification/bubble/bubblepanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QQueue>

Check warning on line 12 in panels/notification/bubble/bubblepanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQueue> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <appletbridge.h>

Expand Down Expand Up @@ -46,7 +46,7 @@
return false;
}

m_accessor = DBAccessor::instance();
m_accessor = DataAccessorProxy::instance();

connect(m_notificationServer, SIGNAL(notificationStateChanged(qint64, int)), this, SLOT(onNotificationStateChanged(qint64, int)));

Expand Down Expand Up @@ -131,6 +131,11 @@

void BubblePanel::closeBubble(qint64 id)
{
const auto entity = m_accessor->fetchEntity(id);
if (!entity.isValid())
return;

id = entity.bubbleId();
m_bubbles->removeById(id);
}

Expand Down
6 changes: 3 additions & 3 deletions panels/notification/center/notificationcenterpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

#include "notificationcenterpanel.h"

#include "notificationcenterproxy.h"
#include "dataaccessorproxy.h"

Check warning on line 7 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dataaccessorproxy.h" not found.
#include "notificationcenterdbusadaptor.h"
#include "notificationcenterproxy.h"
#include "notifyaccessor.h"
#include "dbaccessor.h"

#include <pluginfactory.h>

Check warning on line 12 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <pluginfactory.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <pluginloader.h>

Check warning on line 13 in panels/notification/center/notificationcenterpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <pluginloader.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <applet.h>
#include <containment.h>
#include <appletbridge.h>
Expand Down Expand Up @@ -75,7 +75,7 @@

DPanel::init();

auto accessor = notification::DBAccessor::instance();
auto accessor = notification::DataAccessorProxy::instance();
notifycenter::NotifyAccessor::instance()->setDataAccessor(accessor);

bool valid = false;
Expand Down
11 changes: 11 additions & 0 deletions panels/notification/center/notifyitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,15 @@ NotifyEntity AppGroupNotifyItem::lastEntity() const
{
return m_lastEntity;
}

BubbleNotifyItem::BubbleNotifyItem(const NotifyEntity &entity)
: AppNotifyItem(entity)
{
}

qint64 BubbleNotifyItem::id() const
{
Q_ASSERT(m_entity.isValid());
return m_entity.bubbleId();
}
}
15 changes: 11 additions & 4 deletions panels/notification/center/notifyitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class AppNotifyItem : public QObject
{
Q_OBJECT
public:
AppNotifyItem(const NotifyEntity &entity);
explicit AppNotifyItem(const NotifyEntity &entity);

void setEntity(const NotifyEntity &entity);
NotifyEntity entity() const;

virtual NotifyType type() const;
QString appName() const;
QString appId() const;
qint64 id() const;
virtual qint64 id() const;
QString time() const;
void updateTime();
bool strongInteractive() const;
Expand All @@ -56,10 +56,17 @@ class AppNotifyItem : public QObject
bool m_strongInteractive = false;
};

class BubbleNotifyItem : public AppNotifyItem
{
public:
explicit BubbleNotifyItem(const NotifyEntity &entity);
qint64 id() const override;
};

class OverlapAppNotifyItem : public AppNotifyItem
{
public:
OverlapAppNotifyItem(const NotifyEntity &entity);
explicit OverlapAppNotifyItem(const NotifyEntity &entity);
virtual NotifyType type()const override;
// source 3 -> overlap 2, 2 -> overlap 1, 1-> 0.
void updateCount(int source);
Expand All @@ -78,7 +85,7 @@ class OverlapAppNotifyItem : public AppNotifyItem
class AppGroupNotifyItem : public AppNotifyItem
{
public:
AppGroupNotifyItem(const QString &appName);
explicit AppGroupNotifyItem(const QString &appName);
virtual NotifyType type() const override;

void updateLastEntity(const NotifyEntity& entity);
Expand Down
18 changes: 11 additions & 7 deletions panels/notification/center/notifystagingmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

#include "notifystagingmodel.h"

#include <QTimerEvent>

Check warning on line 7 in panels/notification/center/notifystagingmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimerEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QLoggingCategory>

Check warning on line 8 in panels/notification/center/notifystagingmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "dataaccessorproxy.h"
#include "notifyaccessor.h"
#include "notifyentity.h"
#include "notifyitem.h"
#include "notifyaccessor.h"
#include "dbaccessor.h"
#include "notifysetting.h"

namespace notification {
Expand All @@ -20,7 +20,7 @@

NotifyStagingModel::NotifyStagingModel(QObject *parent)
: QAbstractListModel(parent)
, m_accessor(DBAccessor::instance())
, m_accessor(DataAccessorProxy::instance())
{
connect(NotifyAccessor::instance(), &NotifyAccessor::stagingEntityReceived, this, &NotifyStagingModel::doEntityReceived);
connect(NotifyAccessor::instance(), &NotifyAccessor::stagingEntityClosed, this, &NotifyStagingModel::onEntityClosed);
Expand Down Expand Up @@ -142,9 +142,9 @@
newEntity = newEntities.first();
}

qDebug(notifyLog) << "Insert notify" << newEntity.id();
qDebug(notifyLog) << "Insert notify" << newEntity.bubbleId();
beginInsertRows(QModelIndex(), insertedIndex, insertedIndex);
auto notify = new AppNotifyItem(newEntity);
auto notify = new BubbleNotifyItem(newEntity);
m_appNotifies.insert(insertedIndex, notify);
endInsertRows();
}
Expand All @@ -166,7 +166,7 @@

const auto count = std::min(static_cast<int>(entities.size()), BubbleMaxCount);
for (int i = 0; i < count; i++) {
auto notify = new AppNotifyItem(entities.at(i));
auto notify = new BubbleNotifyItem(entities.at(i));
m_appNotifies << notify;
}
updateOverlapCount(entities.size());
Expand Down Expand Up @@ -246,7 +246,7 @@
{
for (int i = 0; i < m_appNotifies.size(); i++) {
auto item = m_appNotifies[i];
if (item->entity().id() == entity.id()) {
if (item->id() == entity.bubbleId()) {
item->setEntity(entity);
const auto index = this->index(i, 0, {});
dataChanged(index, index);
Expand Down Expand Up @@ -309,6 +309,10 @@

void NotifyStagingModel::onEntityClosed(qint64 id)
{
auto entity = m_accessor->fetchEntity(id);
if (!entity.isValid())
return;
id = entity.bubbleId();
remove(id);
}

Expand Down
4 changes: 4 additions & 0 deletions panels/notification/common/dataaccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class DataAccessor
virtual ~DataAccessor()
{
}
virtual bool isValid() const
{
return true;
}
virtual qint64 addEntity(const NotifyEntity &entity) { Q_UNUSED(entity); return 0; }
virtual qint64 replaceEntity(qint64 id, const NotifyEntity &entity)
{
Expand Down
Loading
Loading